Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vdev: log waiting of the first vhost-user request #15

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

zeil
Copy link
Contributor

@zeil zeil commented Feb 3, 2025

No description provided.

vdev.c Outdated
vdev->negotiated_protocol_features = 0;
/* supported_features is being set on handling first GET_FEATURES request */
vdev->supported_features = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем мы добавили зануление этой переменной?

vdev.c Outdated
@@ -591,9 +594,15 @@ static void arm_msg_handling_timer(struct vhd_vdev *vdev, int secs)
#define MSG_ELAPSED_NSEC_LOG_THRESHOLD (500 * NSEC_PER_MSEC)
#endif


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишнее

vdev.c Outdated
@@ -578,7 +578,10 @@ static void arm_msg_handling_timer(struct vhd_vdev *vdev, int secs)
timerfd_settime(vdev->timerfd, 0, &itimer, NULL);
}

/* Every so many seconds report if the message is still being handled */
/* Report every so many seconds if we haven't received GET_FEATURES request */
#define MSG_GET_FEATURES_WAITING_LOG_INTERVAL 30
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы не добавлял новый енам для этого, особо не вижу смысла, тем более что тут идентичное значение

vdev.c Outdated
vhost_req_name(vdev->req), vdev->req,
(intmax_t)elapsed.tv_sec, elapsed.tv_nsec / NSEC_PER_MSEC);
} else {
VHD_OBJ_WARN(vdev, "Still waiting for GET_FEATURES request...");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я так понимаю на самом деле мы тут ждем первого запроса от VM, а не именно GET_FEATURES. Поэтому я бы писал честно: Still waiting for a vhost-user request..., или типо того

vdev.c Outdated
static void vdev_handle_start(struct vhd_vdev *vdev, uint32_t req,
bool ack_pending)
{
/* we need to detach timer_handler only before very first GET_FEATURES request */
if (vdev->supported_features == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very first GET_FEATURES request

Тоже не совсем правда, тут вызовется detach на любое количество запросов до GET_FEATURES, выглядит так что может упасть если клиент пришлет любой другой запрос несколько раз. Так не пойдет

@zeil
Copy link
Contributor Author

zeil commented Feb 4, 2025

Да, я ошибочно посчитал, что запрос GET_FEATURES всегда первый, думал смогу обойтись существующими полями в vdev.

@@ -594,6 +594,9 @@ static void arm_msg_handling_timer(struct vhd_vdev *vdev, int secs)
static void vdev_handle_start(struct vhd_vdev *vdev, uint32_t req,
bool ack_pending)
{
/* detach timer_handler attached right after accept, no-op after the first request */
vhd_detach_io_handler(vdev->timer_handler);
Copy link
Contributor Author

@zeil zeil Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так было сделать проще всего.
Тут остается вот такой редкий кейс: мы задетачили дескриптор из epoll, но таймер все еще возведен и не зафайрился. У нас есть промежуток времени на строках 609-610, когда мы сначала лобавляем timerfd обратно в epoll, а потом переустанавливаем таймер. Теоретически может случиться так, что в этот промежуток времени напишется сообщение Still waiting...
Я думаю, что это почти невозможный кейс и ради него усложнять патч не стоит.
Тем не менее есть такие варианты:

  • поменять местами строки 609-610, т.е. сначала делать arm_msg_handling_timer, а затем vhd_attach_io_handler. Может быть, это и логично. Как раз будет обратный порядок тому, что в vdev_handle_finish. Врядли epoll_ctl сильно много времени займет в процессе хэндлинга.
  • сделать в vhd_detach_io_handler возвращаемое значение, которые бы показывало, был ли реально произведен детач или нет, и по нему сделать if тут

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Звучит так что поменять порядок, в общем-то, разумно. Давай наверное так и сделаем тут

@zeil zeil changed the title vdev: log waiting of the first GET_FEATURES request vdev: log waiting of the first vhost-user request Feb 4, 2025
@d-tatianin d-tatianin merged commit b623ba6 into yandex-cloud:master Feb 4, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants