[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20120412160912.ee326702.akpm@linux-foundation.org>
Date: Thu, 12 Apr 2012 16:09:12 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: handai.szj@...il.com
Cc: linux-kernel@...r.kernel.org, davidel@...ilserver.org,
Sha Zhengju <handai.szj@...bao.com>
Subject: Re: [PATCH] eventfd: change int to __u64 in eventfd_signal()
On Thu, 12 Apr 2012 18:01:20 +0800
handai.szj@...il.com wrote:
> From: Sha Zhengju <handai.szj@...bao.com>
>
> From: Sha Zhengju <handai.szj@...bao.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.
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().
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists