public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jiufei Xue <[email protected]>
To: Pavel Begunkov <[email protected]>,
	Jens Axboe <[email protected]>,
	[email protected]
Cc: [email protected]
Subject: Re: [PATCH v3 1/2] io_uring: change the poll events to be 32-bits
Date: Wed, 17 Jun 2020 09:39:52 +0800	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 2020/6/17 上午5:46, Pavel Begunkov wrote:
> On 16/06/2020 22:21, Jens Axboe wrote:
>>
>> Nah this won't work, as the BE layout will be different. So how about
>> this, just add a 16-bit poll_events_hi instead. App/liburing will set
>> upper bits there. Something like the below, then just needs the
>> exclusive wait change on top.
>>
>> Only downside I can see is that newer applications on older kernels will
>> set EPOLLEXCLUSIVE but the kernel will ignore it. That's not a huge
>> concern for this particular bit, but could be a concern if there are
>> others that prove useful.
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index de1175206807..a9d74330ad6b 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -4809,6 +4809,9 @@ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
>>  	events = READ_ONCE(sqe->poll_events);
>>  	poll->events = demangle_poll(events) | EPOLLERR | EPOLLHUP;
>>  
>> +	if (READ_ONCE(sqe->poll_events_hi) & EPOLLEXCLUSIVE)
> 
> poll_events_hi is 16 bit, EPOLLEXCLUSIVE is (1 << 28). It's always false.
> Do you look for something like below?
> 
> 
> union {
> 	...
> 	__u32		fsync_flags;
> 	__u16		poll_events;  /* compatibility */
> 	__u32		poll32_events; /* word-reversed for BE */
> };
> 
> u32 evs = READ_ONCE(poll32_events);
> if (BIG_ENDIAN)
> 	evs = swahw32(evs); // swap 16-bit halves
> 
> // use as always, e.g. if (evs & EPOLLEXCLUSIVE) { ... }
>
Cool, That's clear. And we should do the reverse thing in liburing
for big endian.

I also want to add another feature bit in newer kernel, so that
the newer application should check the feature first before setting
the EPOLLEXCLUSIVE.

Thanks,
JIufei.

>> +		poll->events |= EPOLLEXCLUSIVE;
>> +
>>  	io_get_req_task(req);
>>  	return 0;
>>  }
>> diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
>> index 92c22699a5a7..e6856d8e068f 100644
>> --- a/include/uapi/linux/io_uring.h
>> +++ b/include/uapi/linux/io_uring.h
>> @@ -31,7 +31,10 @@ struct io_uring_sqe {
>>  	union {
>>  		__kernel_rwf_t	rw_flags;
>>  		__u32		fsync_flags;
>> -		__u16		poll_events;
>> +		struct {
>> +			__u16	poll_events;
>> +			__u16	poll_events_hi;
>> +		};
>>  		__u32		sync_range_flags;
>>  		__u32		msg_flags;
>>  		__u32		timeout_flags;
>>
> 

  parent reply	other threads:[~2020-06-17  1:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-12  2:30 [PATCH v3] io_uring: add EPOLLEXCLUSIVE flag for POLL_ADD operation Jiufei Xue
2020-06-12  2:30 ` [PATCH v3 1/2] io_uring: change the poll events to be 32-bits Jiufei Xue
2020-06-12 14:58   ` Jens Axboe
2020-06-12 16:48     ` Jens Axboe
2020-06-15  2:49       ` Jiufei Xue
2020-06-15 15:09         ` Jens Axboe
2020-06-16  3:04           ` Jiufei Xue
2020-06-16 13:58             ` Jens Axboe
2020-06-16 18:45               ` Jens Axboe
2020-06-16 19:20                 ` Pavel Begunkov
2020-06-16 19:27                   ` Jens Axboe
2020-06-16 19:21                 ` Jens Axboe
2020-06-16 21:46                   ` Pavel Begunkov
2020-06-17  0:06                     ` Jens Axboe
2020-06-17  1:39                     ` Jiufei Xue [this message]
2020-06-12  2:30 ` [PATCH v3 2/2] io_uring: use EPOLLEXCLUSIVE flag to aoid thundering herd type behavior Jiufei Xue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bc057eb0-2af5-3370-3734-fbe7d9284a5f@linux.alibaba.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox