Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp1159209rdf; Wed, 22 Nov 2023 07:08:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPXT7Lt5xpcoOWBy/0i1asmfpbnTCZert70d72EjzSn3dyl+Zh7fNhoekDJph1wi7dgfOK X-Received: by 2002:a05:6870:8a0a:b0:1d5:eb1:c587 with SMTP id p10-20020a0568708a0a00b001d50eb1c587mr3279022oaq.19.1700665724498; Wed, 22 Nov 2023 07:08:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700665724; cv=none; d=google.com; s=arc-20160816; b=znPOQ6hroS4DTAd4TICgvJw5fXMwoFPE1QWLx2Wg+58qmsE2uAhizH4eVFWZ1Wf0Y3 /VOhAK8yiZxjER57w9C1InykcCJ/rmmh1CKM6tBcrDKYgF+j6y3GxEFe5OpcOeHl44mB JWSt0Z1Q3UfVCYBuqA3TbCk5M4SH3OJikubGDkLFr+XG0qlFTkUO8sRZiJf686hPwBUC XZCmhCevnFmX9xuQGHFfrQpw+YgHRM501vieyrTF8BtE3IYod6jBhUyD86bEdETsGSjD m4Ar0iHAU5paBzg8j1F9QkgrPlZu3/QALDPU/XLnnWbZT/vKIMZO8fBtf7IGy2fjB4L7 frQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=OrnR+VJ3e8KBiB9GJuzndO2GMUtaDExl7p2e9XDoJNY=; fh=o4Dq6GeO+YpuBESu7iIWE8q03XQ/heY11JZf4WM67Zs=; b=bZkjw7GEE34tQScer55q0dxUD6vmZi5oTELbQn6Cd0OfPmcH1fjwxapXet71zlgbjV HNWQOcY9L4Rd4BvIw2tSPB+Ob86hoNQZoidANMNVIJqE5/z2FOlYslLRDvIvo8JUTtS1 ySeP/NCa7BNf0jovMDzfRisHFTfv3WVqD6na6LeMttfcOIe3kSp5aAikDPmTiettqhYO SV301yXuOK1S4xgny+PtNaDUg9qzIQSLkH+WeJMiDeum7m72WXZ4dwbhf6aNY88MUVYf Lou1QBo30CX5jbk5oo7HwkmjIOy8ZjWFHb9PjVrBOL8rFtsv/+wNp8MVDIsmmL1vVM3o 2N0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=I3VUEh0n; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id hf17-20020a0568707a1100b001f967d3e8a6si1455158oab.12.2023.11.22.07.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 07:08:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=I3VUEh0n; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5B6B18068A02; Wed, 22 Nov 2023 07:06:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344090AbjKVPGu (ORCPT + 99 others); Wed, 22 Nov 2023 10:06:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231655AbjKVPGt (ORCPT ); Wed, 22 Nov 2023 10:06:49 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96AC519D; Wed, 22 Nov 2023 07:06:45 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C1BAC1F385; Wed, 22 Nov 2023 15:06:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1700665603; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OrnR+VJ3e8KBiB9GJuzndO2GMUtaDExl7p2e9XDoJNY=; b=I3VUEh0nmQg+RePNSu00a2BA3dlsre6v2YtGb07RjTtCKrjUi1ICIvIdzbKon9Yt4/fQBk VJ9Wpf2K7cyzFS9zBCBUo6IIvILDDyL1bskUFqE+WQg5nj7WUeYGI/EZaADq7d9raLMLVq j2J5KyiS0r9zuduA6j3dmaOBYhZXsr0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1700665603; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OrnR+VJ3e8KBiB9GJuzndO2GMUtaDExl7p2e9XDoJNY=; b=HaijsBJyT5xIphmfAgcIDItAfIvsHToSSGgn6ij0vk97n2OBQT7+g9z+2+NA7fWsCj8Wob +nqu+eTHutvkdWDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B44C113467; Wed, 22 Nov 2023 15:06:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EEn8KwMZXmXdGgAAMHmgww (envelope-from ); Wed, 22 Nov 2023 15:06:43 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 4E863A07DC; Wed, 22 Nov 2023 16:06:43 +0100 (CET) Date: Wed, 22 Nov 2023 16:06:43 +0100 From: Jan Kara To: Christian Brauner Cc: linux-fsdevel@vger.kernel.org, Christoph Hellwig , Jan Kara , Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, David Woodhouse , Paul Durrant , Oded Gabbay , Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Leon Romanovsky , Jason Gunthorpe , Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Greg Kroah-Hartman , Eric Farman , Matthew Rosato , Halil Pasic , Vineeth Vijayan , Peter Oberparleiter , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Tony Krowiak , Jason Herne , Harald Freudenberger , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Diana Craciun , Alex Williamson , Eric Auger , Fei Li , Benjamin LaHaise , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Kirti Wankhede , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fpga@vger.kernel.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-rdma@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-usb@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-aio@kvack.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Jens Axboe , Pavel Begunkov , io-uring@vger.kernel.org Subject: Re: [PATCH v2 4/4] eventfd: make eventfd_signal{_mask}() void Message-ID: <20231122150643.5b57p5yxhfuxa764@quack3> References: <20231122-vfs-eventfd-signal-v2-0-bd549b14ce0c@kernel.org> <20231122-vfs-eventfd-signal-v2-4-bd549b14ce0c@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231122-vfs-eventfd-signal-v2-4-bd549b14ce0c@kernel.org> Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -6.30 X-Spamd-Result: default: False [-6.30 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; BAYES_HAM(-3.00)[100.00%]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_GT_50(0.00)[78]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; FREEMAIL_CC(0.00)[vger.kernel.org,lst.de,suse.cz,redhat.com,google.com,linutronix.de,alien8.de,linux.intel.com,kernel.org,infradead.org,xen.org,intel.com,gmail.com,ffwll.ch,ziepe.ca,linux.ibm.com,arndb.de,linuxfoundation.org,linux.alibaba.com,oss.nxp.com,kvack.org,cmpxchg.org,linux.dev,nvidia.com,lists.freedesktop.org,lists.ozlabs.org,lists.linux-foundation.org,kernel.dk]; RCVD_COUNT_TWO(0.00)[2]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 07:06:52 -0800 (PST) On Wed 22-11-23 13:48:25, Christian Brauner wrote: > No caller care about the return value. > > Signed-off-by: Christian Brauner Yup. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/eventfd.c | 40 +++++++++++++++------------------------- > include/linux/eventfd.h | 16 +++++++--------- > 2 files changed, 22 insertions(+), 34 deletions(-) > > diff --git a/fs/eventfd.c b/fs/eventfd.c > index a9a6de920fb4..13be2fb7fc96 100644 > --- a/fs/eventfd.c > +++ b/fs/eventfd.c > @@ -43,10 +43,19 @@ struct eventfd_ctx { > int id; > }; > > -__u64 eventfd_signal_mask(struct eventfd_ctx *ctx, __poll_t mask) > +/** > + * eventfd_signal - Adds @n to the eventfd counter. > + * @ctx: [in] Pointer to the eventfd context. > + * @mask: [in] poll mask > + * > + * This function is supposed to be called by the kernel in paths that do not > + * allow sleeping. In this function we allow the counter to reach the ULLONG_MAX > + * value, and we signal this as overflow condition by returning a EPOLLERR > + * to poll(2). > + */ > +void eventfd_signal_mask(struct eventfd_ctx *ctx, __poll_t mask) > { > unsigned long flags; > - __u64 n = 1; > > /* > * Deadlock or stack overflow issues can happen if we recurse here > @@ -57,37 +66,18 @@ __u64 eventfd_signal_mask(struct eventfd_ctx *ctx, __poll_t mask) > * safe context. > */ > if (WARN_ON_ONCE(current->in_eventfd)) > - return 0; > + return; > > spin_lock_irqsave(&ctx->wqh.lock, flags); > current->in_eventfd = 1; > - if (ULLONG_MAX - ctx->count < n) > - n = ULLONG_MAX - ctx->count; > - ctx->count += n; > + if (ctx->count < ULLONG_MAX) > + ctx->count++; > if (waitqueue_active(&ctx->wqh)) > wake_up_locked_poll(&ctx->wqh, EPOLLIN | mask); > current->in_eventfd = 0; > spin_unlock_irqrestore(&ctx->wqh.lock, flags); > - > - return n == 1; > -} > - > -/** > - * eventfd_signal - Adds @n to the eventfd counter. > - * @ctx: [in] Pointer to the eventfd context. > - * > - * This function is supposed to be called by the kernel in paths that do not > - * allow sleeping. In this function we allow the counter to reach the ULLONG_MAX > - * value, and we signal this as overflow condition by returning a EPOLLERR > - * to poll(2). > - * > - * Returns the amount by which the counter was incremented. > - */ > -__u64 eventfd_signal(struct eventfd_ctx *ctx) > -{ > - return eventfd_signal_mask(ctx, 0); > } > -EXPORT_SYMBOL_GPL(eventfd_signal); > +EXPORT_SYMBOL_GPL(eventfd_signal_mask); > > static void eventfd_free_ctx(struct eventfd_ctx *ctx) > { > diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h > index 4f8aac7eb62a..fea7c4eb01d6 100644 > --- a/include/linux/eventfd.h > +++ b/include/linux/eventfd.h > @@ -35,8 +35,7 @@ void eventfd_ctx_put(struct eventfd_ctx *ctx); > struct file *eventfd_fget(int fd); > struct eventfd_ctx *eventfd_ctx_fdget(int fd); > struct eventfd_ctx *eventfd_ctx_fileget(struct file *file); > -__u64 eventfd_signal(struct eventfd_ctx *ctx); > -__u64 eventfd_signal_mask(struct eventfd_ctx *ctx, __poll_t mask); > +void eventfd_signal_mask(struct eventfd_ctx *ctx, __poll_t mask); > int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_entry_t *wait, > __u64 *cnt); > void eventfd_ctx_do_read(struct eventfd_ctx *ctx, __u64 *cnt); > @@ -58,14 +57,8 @@ static inline struct eventfd_ctx *eventfd_ctx_fdget(int fd) > return ERR_PTR(-ENOSYS); > } > > -static inline int eventfd_signal(struct eventfd_ctx *ctx) > +static inline void eventfd_signal_mask(struct eventfd_ctx *ctx, unsigned mask) > { > - return -ENOSYS; > -} > - > -static inline int eventfd_signal_mask(struct eventfd_ctx *ctx, unsigned mask) > -{ > - return -ENOSYS; > } > > static inline void eventfd_ctx_put(struct eventfd_ctx *ctx) > @@ -91,5 +84,10 @@ static inline void eventfd_ctx_do_read(struct eventfd_ctx *ctx, __u64 *cnt) > > #endif > > +static inline void eventfd_signal(struct eventfd_ctx *ctx) > +{ > + eventfd_signal_mask(ctx, 0); > +} > + > #endif /* _LINUX_EVENTFD_H */ > > > -- > 2.42.0 > -- Jan Kara SUSE Labs, CR