Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5180709rwd; Mon, 12 Jun 2023 00:51:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6//nPN8Tr9xxsG+Zq4l4q2dkFg/bfTY/263e/YyHEX52r26ijdnHTZ+Yoe9HD3yCKQ9WGc X-Received: by 2002:a17:902:8505:b0:1af:de3d:bbe3 with SMTP id bj5-20020a170902850500b001afde3dbbe3mr5686746plb.26.1686556270420; Mon, 12 Jun 2023 00:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686556270; cv=none; d=google.com; s=arc-20160816; b=KUjhWZHZZH1qOtPvEb6/bN03Mja9kNWRPloWo1XKzprj9p9sojZorsRgLG4sIIws/B fGz30hvmdg7hfPkuwmy3depDfG/uuLy53R1C7+PI+NOdm2RZm5CtQZST6J14Z/sOwSXA HxDcQ4msILlTL90IwBDL83n2pk2dZ4N4UilXaTqZnZeCe3X8b+DXDKhui/auURJwhHZ+ fUIEVHlw+aTZXnNaPzM34BSBfT41rcR9yAfAqvviL7LfNGytKLu/0u2EBMCYybAXWl5E ptOds4SQvJe0ngyKrcOhTkScVzLdXeoAgyYebRvpFKp38tF1UnVI0UM6KKwnWAW1P+Pg WvDA== 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; bh=osR65wTr68Jos9lgIYRP6L+dEnSYW9l8OQC5/U8ktp8=; b=0Ip2/WVx+Chk60LJuxw1umbznTkxm2TJ3Z3G++21xLJgpIOCuPjikxyD+rIF3HeNE5 Ws8wbxGKtyBFw0507JgkF86kq6+snLuID+3qRUXEuiGpTKxzKxm2ZsNB8dhJyaLQYGN5 sC6zI5gWWejZinIWddBdvwAzf9mpH+kjAG5YpsOB1YmUGyQw8cvhfD4fBUBr0c6cok8F SiFhqwoZ5/BV4a2aOmdLJYwtRBLRRaad+MT0SKGrr9zwvSbpKq17wAqLZRELsnkXfP78 jrJ9GYxpsoSCjHhrOUsTG+uw2Xws5TkWGSfU2+slGrqE+o7+vR1/MZFcHCu068LJofZg IQpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UVqte4ZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c16-20020a170903235000b001ae3fa8de08si4011789plh.576.2023.06.12.00.50.58; Mon, 12 Jun 2023 00:51:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UVqte4ZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235410AbjFLHrO (ORCPT + 99 others); Mon, 12 Jun 2023 03:47:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234959AbjFLHrM (ORCPT ); Mon, 12 Jun 2023 03:47:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8882B19B7; Mon, 12 Jun 2023 00:46:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B70C861158; Mon, 12 Jun 2023 07:45:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE889C433EF; Mon, 12 Jun 2023 07:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686555933; bh=fNNa/Ten3TAlzVZUvP7Qr28Og4PiRtD+xLvGhMlIHD4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UVqte4ZR8kr8QRufriFvaxb3GbJ16a6Ry+QujPy8QHRA0g1eaOqnUP7XKFByaeMbS PIBzA+ic9BrmYEA0rhLrMz8G+OSyRqkJ6iHqQEWWL/MOtZhYDtQ2SDEtlgoCUWloW7 HETVfw5tOhenB7hvWOsHXtnlsyJyn/zPJakfUcXI+n30d8Q6tpT8N8zKOMvICFZk7X 7pcNsXOUlsbPvJduhngeBouustBapzDAoasJl2GFuQchKPJ4CPhdLs7V9+xWsBa0ph 448DKiqNWI8LwhWv59HbzFEplFlBQvgeIFZ8eVz0f5TU7QXFKgrEczNLK/onFaEG2f ZZJ451H7DYVnA== Date: Mon, 12 Jun 2023 09:45:28 +0200 From: Christian Brauner To: wenyang.linux@foxmail.com Cc: Alexander Viro , Jens Axboe , Christoph Hellwig , Dylan Yudaken , David Woodhouse , Matthew Wilcox , Eric Biggers , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] eventfd: show flags in fdinfo Message-ID: <20230612-atomkraftgegner-erziehen-8ee4a0c9c606@brauner> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Mon, Jun 12, 2023 at 02:59:47AM +0800, wenyang.linux@foxmail.com wrote: > From: Wen Yang > > The flags should be displayed in fdinfo, as different flags > could affect the behavior of eventfd. > > Signed-off-by: Wen Yang > Cc: Alexander Viro > Cc: Jens Axboe > Cc: Christian Brauner > Cc: Christoph Hellwig > Cc: Dylan Yudaken > Cc: David Woodhouse > Cc: Matthew Wilcox > Cc: Eric Biggers > Cc: linux-fsdevel@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > --- > fs/eventfd.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/fs/eventfd.c b/fs/eventfd.c > index 6c06a527747f..5b5448e65f6f 100644 > --- a/fs/eventfd.c > +++ b/fs/eventfd.c > @@ -33,10 +33,10 @@ struct eventfd_ctx { > /* > * Every time that a write(2) is performed on an eventfd, the > * value of the __u64 being written is added to "count" and a > - * wakeup is performed on "wqh". A read(2) will return the "count" > - * value to userspace, and will reset "count" to zero. The kernel > - * side eventfd_signal() also, adds to the "count" counter and > - * issue a wakeup. > + * wakeup is performed on "wqh". If EFD_SEMAPHORE flag was not > + * specified, a read(2) will return the "count" value to userspace, > + * and will reset "count" to zero. The kernel side eventfd_signal() > + * also, adds to the "count" counter and issue a wakeup. > */ > __u64 count; > unsigned int flags; > @@ -301,6 +301,7 @@ static void eventfd_show_fdinfo(struct seq_file *m, struct file *f) > (unsigned long long)ctx->count); > spin_unlock_irq(&ctx->wqh.lock); > seq_printf(m, "eventfd-id: %d\n", ctx->id); > + seq_printf(m, "eventfd-flags: 0%o\n", ctx->flags); EFD_CLOEXEC and EFD_NONBLOCK are mapped to generic O_* flags and are included in fdinfo output already: pos: 0 flags: 02000002 -> O_CLOEXEC/EFD_CLOEXEC | O_RDWR mnt_id: 15 ino: 12497 eventfd-count: 0 eventfd-id: 156 So the only thing you really care about is EFD_SEMAPHORE. Since this changes the type of the eventfd I would just do either: eventfd-semaphore: {0,1} or - if we can reasonably expect a third type: eventfd-type: {0, ..., n} though I suspect since it hasn't changed since 2.6-something that eventfd-semaphore: {0,1} is probably fine. so you only really care about EFD_SEMAPHORE.