From: Paolo Bonzini Subject: Re: [PATCH 1/2] eventfd: reorganize the code to simplify new flags Date: Thu, 27 Aug 2009 13:48:53 +0200 Message-ID: <4A9672A5.60004@gnu.org> References: <20090820155703.GB8764@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: davidel@xmailserver.org, avi@redhat.com, gleb@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: "Michael S. Tsirkin" Return-path: In-Reply-To: <20090820155703.GB8764@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 08/20/2009 05:57 PM, Michael S. Tsirkin wrote: > +static inline int eventfd_writeable(struct eventfd_ctx *ctx, u64 n) > +{ > + return ULLONG_MAX - n> ctx->count; > +} > + > +static inline void eventfd_dowrite(struct eventfd_ctx *ctx, u64 ucnt) > +{ > + if (eventfd_writeable(ctx, ucnt)) > + ucnt = ULLONG_MAX - ctx->count; > + > + ctx->count += ucnt; In any case, this usage of eventfd_writeable is wrong: the code was like this: - if (ULLONG_MAX - ctx->count < n) - n = (int) (ULLONG_MAX - ctx->count); - ctx->count += n; + eventfd_dowrite(ctx, n); and so it should be !eventfd_writable. (This smelled when I was editing patch 2, so I went back and checked patch 1). Paolo