Re: epoll_wait returning EFAULT on Linux 3.2.78

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: epoll_wait returning EFAULT on Linux 3.2.78
Дата
Msg-id 30139.1464890208@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: epoll_wait returning EFAULT on Linux 3.2.78  (Andres Freund <andres@anarazel.de>)
Ответы Re: epoll_wait returning EFAULT on Linux 3.2.78  (Greg Stark <stark@mit.edu>)
Список pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> On 2016-06-02 18:41:00 +0100, Greg Stark wrote:
>> Well there's not *nothing* we can do. I thought I we were going to
>> have to go back and do manual offset calculations to get that right.

> The kernel accesses the elements as an array. If the array stride (by
> virtue of sizeof) were wrong, we couldn't fix that.

Right.  The general rule in C is that sizeof(anything) is always a
multiple of the something's alignment requirement, so that if you
have a correctly aligned initial element of an array then later
elements are also correctly aligned.  The problem in our existing
code is that sizeof(WaitEventSet) might not be a multiple of the
alignment requirement of WaitEvent, and either of those two might
not be a multiple of the alignment requirement of struct epoll_event,
etc.  So we should make the code look like
sz += MAXALIGN(sizeof(WaitEventSet));sz += MAXALIGN(sizeof(WaitEvent) * nevents);

#if defined(WAIT_USE_EPOLL)sz += MAXALIGN(sizeof(struct epoll_event) * nevents);

etc, so that each of the subsidiary arrays starts on a MAXALIGN boundary.
Where the later array elements fall is taken care of given that.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: Typo in comment in nbtree.h
Следующее
От: Greg Stark
Дата:
Сообщение: Re: epoll_wait returning EFAULT on Linux 3.2.78