From patchwork Tue Jun 13 17:01:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Yang X-Patchwork-Id: 13279046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06846EB64D0 for ; Tue, 13 Jun 2023 17:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235021AbjFMRBm (ORCPT ); Tue, 13 Jun 2023 13:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231348AbjFMRBk (ORCPT ); Tue, 13 Jun 2023 13:01:40 -0400 X-Greylist: delayed 165714 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 13 Jun 2023 10:01:37 PDT Received: from out203-205-251-59.mail.qq.com (out203-205-251-59.mail.qq.com [203.205.251.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2908C19B1; Tue, 13 Jun 2023 10:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1686675689; bh=WN3EO5L6L2LgUO17F1OB+6gZgNsH9LQG50fu8rjPAmw=; h=From:To:Cc:Subject:Date; b=RwlL8Hu6NjuOw1HA4xLw38JZdkmtp+YE8KyXfqlJ24Xz9GZaX7J+jXi9AufCW9JVy urgOp+7SzZSKoYIsPG9uW8nO3MGmTVO5Ej7w3ah2xfjIIqwz6ZE8QGuEpEEQ2onbTA RarFGWq1AUQ5sFLmL+huwBwjRAs+Ez+aUcRI8tHU= Received: from localhost.localdomain ([240e:331:cc9:d200:8f2b:c42a:801a:dea9]) by newxmesmtplogicsvrszc5-0.qq.com (NewEs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qJ AAxJ0yOUnsRTW5DZUWUxVONBicIKo2sTvefZVelUgOeljF0t0dPotLO/HxcflcvWTidgb4nlO2Vc 4s0xPT1fq520hcCkGryrxnH0OTijAwstOgB4INIV/iOzwC6S9F X-QQ-XMAILREADINFO: MFSZYyQdPxvloIttF8cZzD8= From: wenyang.linux@foxmail.com To: Alexander Viro , Jens Axboe , Christian Brauner Cc: Wen Yang , Christoph Hellwig , Dylan Yudaken , David Woodhouse , Matthew Wilcox , Eric Biggers , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] eventfd: show the EFD_SEMAPHORE flag in fdinfo Date: Wed, 14 Jun 2023 01:01:22 +0800 X-OQ-MSGID: <20230613170122.6867-1-wenyang.linux@foxmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Wen Yang The EFD_SEMAPHORE flag should be displayed in fdinfo, as different value could affect the behavior of eventfd. Suggested-by: Christian Brauner 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/eventfd.c b/fs/eventfd.c index 6c06a527747f..8aa36cd37351 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,8 @@ 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-semaphore: %d\n", + !!(ctx->flags & EFD_SEMAPHORE)); } #endif