All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sha Zhengju <handai.szj@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, davidel@xmailserver.org,
	Sha Zhengju <handai.szj@taobao.com>
Subject: Re: [PATCH] eventfd: change int to __u64 in eventfd_signal()
Date: Fri, 13 Apr 2012 10:52:35 +0800	[thread overview]
Message-ID: <4F8794F3.5050503@gmail.com> (raw)
In-Reply-To: <20120412160912.ee326702.akpm@linux-foundation.org>

On 04/13/2012 07:09 AM, Andrew Morton wrote:
> On Thu, 12 Apr 2012 18:01:20 +0800
> handai.szj@gmail.com wrote:
>
>> From: Sha Zhengju<handai.szj@taobao.com>
>>
>> From: Sha Zhengju<handai.szj@taobao.com>
>>
>> eventfd_ctx->count is an __u64 counter which is allowed to reach ULLONG_MAX.
>> Now eventfd_write() add an __u64 value to "count", but kernel side
>> eventfd_signal() only add an int value to it. So make them consistent here.
>>
>> ...
>>
>> --- a/fs/eventfd.c
>> +++ b/fs/eventfd.c
>> @@ -51,7 +51,7 @@ struct eventfd_ctx {
>>    *
>>    * -EINVAL    : The value of @n is negative.
>>    */
>> -int eventfd_signal(struct eventfd_ctx *ctx, int n)
>> +__u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n)
>>   {
>>   	unsigned long flags;
>>
>> @@ -59,7 +59,7 @@ int eventfd_signal(struct eventfd_ctx *ctx, int n)
>>   		return -EINVAL;
>>   	spin_lock_irqsave(&ctx->wqh.lock, flags);
>>   	if (ULLONG_MAX - ctx->count<  n)
>> -		n = (int) (ULLONG_MAX - ctx->count);
>> +		n = ULLONG_MAX - ctx->count;
>>   	ctx->count += n;
>>   	if (waitqueue_active(&ctx->wqh))
>>   		wake_up_locked_poll(&ctx->wqh, POLLIN);
> Changing `n' to an unsigned type makes the "if (n<  0)" test a no-op.
>
yeah, it's really not necessary. I slipped up..
> Every in-kernel caller of eventfd_signal() passes n=1.  All of them.
> Perhaps we can just remove that argument and hard-wire the +1
> assumption into eventfd_signal().
A userspace write(2) performing on an eventfd can pass an u64 value to
"count" and issue a wakeup, I think the kernel side can just be in 
accord with it.
Though all the current in-kernel callers just pass 1 to eventfd_signal(), it
doesn't mean there is no possibility of other usages in future. 
Actually, we're
considering to encode some usefully info to "count" and sent it to 
userspace. :-)


      reply	other threads:[~2012-04-13  2:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-12 10:01 [PATCH] eventfd: change int to __u64 in eventfd_signal() handai.szj
2012-04-12 23:09 ` Andrew Morton
2012-04-13  2:52   ` Sha Zhengju [this message]

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=4F8794F3.5050503@gmail.com \
    --to=handai.szj@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=davidel@xmailserver.org \
    --cc=handai.szj@taobao.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.