The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]



Индекс форумов
Составление сообщения

Исходное сообщение
"Доступен новый гипервизор KSM"
Отправлено Ordu, 02-Фев-17 08:28 
> Harsh replies automatically allocate me as Linus Torvalds, ok.

No, you cannot be used as a replacement for him, but still looks similar. At least your first comment in this thread has such funny property.

> the vcpu_list is not a list_head, it's simply an array of `struct vcpu`, declared as follows:
> struct vcpu vcpu_list[MAX_VCPUS];

Wow... I'm impressed. Unexpected use for container_of. But yes, you are right about I was a fool, I could catch it looking only into this function, but I didn't.

But nevertheless... You are using container_of in a way its not indended to use. Even without looking on the rest of your code I can say this to you with great confidence. If you do not believe me, you might ask any kernel developer and try to convince him that you have important reasons to such a design that leads to use container_of in this case.

container_of is a tool to design some data structures like list, where different struct types have common parts. For example struct list_head field.
container_of is not a magic way to use pointers into structures as substitute for pointers to structures. Because container_of is using explicit casts which is bad. Such casts used everywere in kernel not because it is a good practice, but because C gives no other ways to do some things. Pointer arith even worse, but in some cases its the only choice also. Your case is not valid case for using pointer arith, expicit casts and container_of.

Just add to struct vcpu field `struct ksm *parent', and your vcpu_to_ksm will not need any casts anymore. Its completely safe: such a pointer will not become dangling, because struct vcpu shares lifetime with containing struct ksm. Just do not forget to initialize this pointer.

 

Ваше сообщение
Имя*:
EMail:
Для отправки ответов на email укажите знак ! перед адресом, например, !user@host.ru (!! - не показывать email).
Более тонкая настройка отправки ответов производится в профиле зарегистрированного участника форума.
Заголовок*:
Сообщение*:
  Введите код, изображенный на картинке: КОД
 
При общении не допускается: неуважительное отношение к собеседнику, хамство, унизительное обращение, ненормативная лексика, переход на личности, агрессивное поведение, обесценивание собеседника, провоцирование флейма голословными и заведомо ложными заявлениями. Не отвечайте на сообщения, явно нарушающие правила - удаляются не только сами нарушения, но и все ответы на них. Лог модерирования.



Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру