From mboxrd@z Thu Jan 1 00:00:00 1970 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 6B41BC433F5 for ; Fri, 10 Dec 2021 18:14:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245252AbhLJSRx (ORCPT ); Fri, 10 Dec 2021 13:17:53 -0500 Received: from mail-ot1-f50.google.com ([209.85.210.50]:41580 "EHLO mail-ot1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245272AbhLJSRt (ORCPT ); Fri, 10 Dec 2021 13:17:49 -0500 Received: by mail-ot1-f50.google.com with SMTP id n17-20020a9d64d1000000b00579cf677301so10431064otl.8; Fri, 10 Dec 2021 10:14:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RaOuCzlDrEGoU3kCCyjiPh5ZIczFbf2cAVp5IUpr62Q=; b=aYs7LMndxGQpF02d4DZkmc86npx27c98t9FUhb00GPqmlpfzrDoHJSQAdPtHMLb4ZT sBgEFGPVqlxMhz9CL8d6NEjNXDJ00/Dn+GVsVJQWoB6F3WnWtzX04Oc1yVZTCPjqFaDn pg7aBS6C5RgxjWnO3mqThntNTG0GPO/p6/NL9Gc+VpFmnYOCxJu+Kup89a7HZaI2mZPi pY3YahmWNV1qPpsWlk4sUc1PiBEAk3/QXfVxMNfiYxlFHiZyqqjebHVL+t4YaI2tG2+8 LZ/8XdpAAqs6XlO/Okhl+gqgoHLaz5SH2vBprAB4/uQhVPdD0zLNey6keZpW+EXJRU6x smpg== X-Gm-Message-State: AOAM532adB4yICiE7ElTW/1QWw2JxmvASw1hXzicLGSu5KzReFzRJSn1 +uwiJ1itRFIqsnUsofHij1+XUFlMjNykQavrK8w= X-Google-Smtp-Source: ABdhPJx5VEl25dlL8StyZ7/vR+sIp4uhzbZQ+4jxftcUhgC3Wucypp0Twl9yCOfT1qw70j5+PgOSc5gj4QOVrzsPiE4= X-Received: by 2002:a9d:4c10:: with SMTP id l16mr12483219otf.198.1639160053505; Fri, 10 Dec 2021 10:14:13 -0800 (PST) MIME-Version: 1.0 References: <20211126180101.27818-1-digetx@gmail.com> <20211126180101.27818-3-digetx@gmail.com> In-Reply-To: <20211126180101.27818-3-digetx@gmail.com> From: "Rafael J. Wysocki" Date: Fri, 10 Dec 2021 19:14:02 +0100 Message-ID: Subject: Re: [PATCH v4 02/25] notifier: Add blocking_notifier_call_chain_is_empty() To: Dmitry Osipenko Cc: Thierry Reding , Jonathan Hunter , Russell King , Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Sebastian Reichel , Linus Walleij , Philipp Zabel , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "the arch/x86 maintainers" , "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , "Rafael J. Wysocki" , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , Pavel Machek , Lee Jones , Andrew Morton , Guenter Roeck , Daniel Lezcano , Andy Shevchenko , Ulf Hansson , alankao@andestech.com, "K . C . Kuen-Chern Lin" , Linux ARM , Linux Kernel Mailing List , linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev , linux-riscv@lists.infradead.org, Linux-sh list , xen-devel@lists.xenproject.org, ACPI Devel Maling List , Linux PM , linux-tegra Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org On Fri, Nov 26, 2021 at 7:01 PM Dmitry Osipenko wrote: > > Add blocking_notifier_call_chain_is_empty() that returns true if call > chain is empty. > > Signed-off-by: Dmitry Osipenko > --- > include/linux/notifier.h | 2 ++ > kernel/notifier.c | 14 ++++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/include/linux/notifier.h b/include/linux/notifier.h > index 4b80a815b666..924c9d7c8e73 100644 > --- a/include/linux/notifier.h > +++ b/include/linux/notifier.h > @@ -173,6 +173,8 @@ int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh, > int raw_notifier_call_chain_robust(struct raw_notifier_head *nh, > unsigned long val_up, unsigned long val_down, void *v); > > +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh); > + > #define NOTIFY_DONE 0x0000 /* Don't care */ > #define NOTIFY_OK 0x0001 /* Suits me */ > #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ > diff --git a/kernel/notifier.c b/kernel/notifier.c > index b8251dc0bc0f..b20cb7b9b1f0 100644 > --- a/kernel/notifier.c > +++ b/kernel/notifier.c > @@ -322,6 +322,20 @@ int blocking_notifier_call_chain(struct blocking_notifier_head *nh, > } > EXPORT_SYMBOL_GPL(blocking_notifier_call_chain); > > +/** > + * blocking_notifier_call_chain_is_empty - Check whether notifier chain is empty > + * @nh: Pointer to head of the blocking notifier chain > + * > + * Checks whether notifier chain is empty. > + * > + * Returns true is notifier chain is empty, false otherwise. > + */ > +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh) > +{ > + return !rcu_access_pointer(nh->head); > +} > +EXPORT_SYMBOL_GPL(blocking_notifier_call_chain_is_empty); The check is not reliable (racy) without locking, so I wouldn't export anything like this to modules. At least IMO it should be added along with a user. From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E24EC433EF for ; Fri, 10 Dec 2021 18:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PzU0h5o3mcEdhsNZSZusfjhcCIliaeyWFfy0DcTVj6k=; b=d+Gp0ThvRMWpZ8 tZ5YVJZSVJyg5cII2H++b7gflC71LS4l3egiHRwIHlMVcToxIuKciLBffRyIFRBHInXd5iVMn8k6X 2uZeF40GN7741xCpr4frGOX3FsxWcPK2N2HOVJihCDhu7snVp7xt9xCT1zQE6SA3Mkie4fph0LkVf MXyDVSjNydlvetCLPO413gxbt1ekCcM9dCF4LCmX5CrWutPOF9EeZWlkxPza6VBnkx2LIaZ4HjSoK NLVN/OyblO3wixPQ3kCEvNkTwuItQo+3OOKtC+Ld4fqLtw+u7pRYQIseniCKuHU5GulwWC7ek/eEj gDHI6YOLsjcXA0amFaxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvkPS-003AGb-PA; Fri, 10 Dec 2021 18:14:18 +0000 Received: from mail-ot1-f48.google.com ([209.85.210.48]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvkPO-003AEJ-EC; Fri, 10 Dec 2021 18:14:16 +0000 Received: by mail-ot1-f48.google.com with SMTP id h19-20020a9d3e53000000b0056547b797b2so10420438otg.4; Fri, 10 Dec 2021 10:14:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RaOuCzlDrEGoU3kCCyjiPh5ZIczFbf2cAVp5IUpr62Q=; b=lW2O+4xxf0jG2RjjTBqUp3ZxOFcGBNm7kOva3N4cywY+M+yKUarBy6EpugBmToWSbE dUrD5eFd8vI0MG9vMpHmKsc3txKtRx9t1v0CNiQI0Fhsbu5jFMuRTTijXQ0NaGhVM15b fNI9h4BvDAgQYzSXBm9sSmWj/agneYD0pzQQavB1TvvN7L7SDmkRLySn/hLxoCTYKc4a D4dBlrgOopdzrlmxCBNH4t1cV+WY6hThrvotpagZ9f8gdQ2ZlC1pSzsy0IO34bbYLPX3 mKJHRyvf5xm4re3BAHV4hONKc2QNHDcfMskz4UuJejsF3VIE2Kjq++fLds1JDUa5we2/ z81w== X-Gm-Message-State: AOAM530BRmJx1EuoJsBLO/JwtC7a0vZlobLbkT0C6Je8gELh+PXgx0hV yR3ENaxYIcRS+UrnrW1eYI+WihBOuj8++ht1zk4= X-Google-Smtp-Source: ABdhPJx5VEl25dlL8StyZ7/vR+sIp4uhzbZQ+4jxftcUhgC3Wucypp0Twl9yCOfT1qw70j5+PgOSc5gj4QOVrzsPiE4= X-Received: by 2002:a9d:4c10:: with SMTP id l16mr12483219otf.198.1639160053505; Fri, 10 Dec 2021 10:14:13 -0800 (PST) MIME-Version: 1.0 References: <20211126180101.27818-1-digetx@gmail.com> <20211126180101.27818-3-digetx@gmail.com> In-Reply-To: <20211126180101.27818-3-digetx@gmail.com> From: "Rafael J. Wysocki" Date: Fri, 10 Dec 2021 19:14:02 +0100 Message-ID: Subject: Re: [PATCH v4 02/25] notifier: Add blocking_notifier_call_chain_is_empty() To: Dmitry Osipenko Cc: Thierry Reding , Jonathan Hunter , Russell King , Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Sebastian Reichel , Linus Walleij , Philipp Zabel , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "the arch/x86 maintainers" , "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , "Rafael J. Wysocki" , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , Pavel Machek , Lee Jones , Andrew Morton , Guenter Roeck , Daniel Lezcano , Andy Shevchenko , Ulf Hansson , alankao@andestech.com, "K . C . Kuen-Chern Lin" , Linux ARM , Linux Kernel Mailing List , linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev , linux-riscv@lists.infradead.org, Linux-sh list , xen-devel@lists.xenproject.org, ACPI Devel Maling List , Linux PM , linux-tegra X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211210_101414_540522_40BDD28D X-CRM114-Status: GOOD ( 19.94 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Fri, Nov 26, 2021 at 7:01 PM Dmitry Osipenko wrote: > > Add blocking_notifier_call_chain_is_empty() that returns true if call > chain is empty. > > Signed-off-by: Dmitry Osipenko > --- > include/linux/notifier.h | 2 ++ > kernel/notifier.c | 14 ++++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/include/linux/notifier.h b/include/linux/notifier.h > index 4b80a815b666..924c9d7c8e73 100644 > --- a/include/linux/notifier.h > +++ b/include/linux/notifier.h > @@ -173,6 +173,8 @@ int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh, > int raw_notifier_call_chain_robust(struct raw_notifier_head *nh, > unsigned long val_up, unsigned long val_down, void *v); > > +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh); > + > #define NOTIFY_DONE 0x0000 /* Don't care */ > #define NOTIFY_OK 0x0001 /* Suits me */ > #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ > diff --git a/kernel/notifier.c b/kernel/notifier.c > index b8251dc0bc0f..b20cb7b9b1f0 100644 > --- a/kernel/notifier.c > +++ b/kernel/notifier.c > @@ -322,6 +322,20 @@ int blocking_notifier_call_chain(struct blocking_notifier_head *nh, > } > EXPORT_SYMBOL_GPL(blocking_notifier_call_chain); > > +/** > + * blocking_notifier_call_chain_is_empty - Check whether notifier chain is empty > + * @nh: Pointer to head of the blocking notifier chain > + * > + * Checks whether notifier chain is empty. > + * > + * Returns true is notifier chain is empty, false otherwise. > + */ > +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh) > +{ > + return !rcu_access_pointer(nh->head); > +} > +EXPORT_SYMBOL_GPL(blocking_notifier_call_chain_is_empty); The check is not reliable (racy) without locking, so I wouldn't export anything like this to modules. At least IMO it should be added along with a user. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F279DC433EF for ; Sun, 12 Dec 2021 22:51:36 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JC0Hq40j5z3cbx for ; Mon, 13 Dec 2021 09:51:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=209.85.210.51; helo=mail-ot1-f51.google.com; envelope-from=rjwysocki@gmail.com; receiver=) Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4J9fDm1jttz3089 for ; Sat, 11 Dec 2021 05:14:16 +1100 (AEDT) Received: by mail-ot1-f51.google.com with SMTP id i5-20020a05683033e500b0057a369ac614so10398316otu.10 for ; Fri, 10 Dec 2021 10:14:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RaOuCzlDrEGoU3kCCyjiPh5ZIczFbf2cAVp5IUpr62Q=; b=4tQCcV5ImDdXJTdkTzBkAshEzojaUcKiimBljVBviBCg6Po3icKh50LwMy3cKX7nf1 y9buBzhn6zGG9EVO6tCsNx2Aq/qPtdvboWFRjxFzirDLK4UiJg83pUNQWMms24fqh+k7 WzyByx0El9Go9TXi6fSPOzcrLJNuftx2Ohg3C46y5TcL7hF5BtzZ9v6nc7bdlpDpJS6+ XqwnExWmBF37TKlQSTcSUG6bo3IQr6o/kOYYtsbUjgDzdPQBUDROBQm2+AlyTbrd3+qT 2+oyckhAka1VGtPPhp1QXudK1V2BzADoPTjGFedj6DOPE/EZFeSoaPMm6jXbCxY4GAih vs+Q== X-Gm-Message-State: AOAM531cTskD8yrO0UT4actKvwjfUZWEFLgmE4ggkgcxoDxMB48WRe3W 4AOMttB399sfetOwGzzRKjP5fdihfSVzov5xssE= X-Google-Smtp-Source: ABdhPJx5VEl25dlL8StyZ7/vR+sIp4uhzbZQ+4jxftcUhgC3Wucypp0Twl9yCOfT1qw70j5+PgOSc5gj4QOVrzsPiE4= X-Received: by 2002:a9d:4c10:: with SMTP id l16mr12483219otf.198.1639160053505; Fri, 10 Dec 2021 10:14:13 -0800 (PST) MIME-Version: 1.0 References: <20211126180101.27818-1-digetx@gmail.com> <20211126180101.27818-3-digetx@gmail.com> In-Reply-To: <20211126180101.27818-3-digetx@gmail.com> From: "Rafael J. Wysocki" Date: Fri, 10 Dec 2021 19:14:02 +0100 Message-ID: Subject: Re: [PATCH v4 02/25] notifier: Add blocking_notifier_call_chain_is_empty() To: Dmitry Osipenko Content-Type: text/plain; charset="UTF-8" X-Mailman-Approved-At: Mon, 13 Dec 2021 09:47:48 +1100 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Rich Felker , linux-ia64@vger.kernel.org, Santosh Shilimkar , "Rafael J. Wysocki" , Boris Ostrovsky , Linus Walleij , Dave Hansen , Liam Girdwood , "James E.J. Bottomley" , Thierry Reding , Paul Mackerras , Pavel Machek , "H. Peter Anvin" , linux-riscv@lists.infradead.org, Vincent Chen , Will Deacon , Greg Ungerer , Stefano Stabellini , alankao@andestech.com, Yoshinori Sato , Krzysztof Kozlowski , Linux-sh list , Helge Deller , the arch/x86 maintainers , Russell King , linux-csky@vger.kernel.org, Jonathan Hunter , ACPI Devel Maling List , Ingo Molnar , Geert Uytterhoeven , Catalin Marinas , xen-devel@lists.xenproject.org, linux-mips@vger.kernel.org, Guenter Roeck , Len Brown , Albert Ou , Lee Jones , linux-m68k@lists.linux-m68k.org, Mark Brown , Borislav Petkov , Greentime Hu , Paul Walmsley , linux-tegra , Thomas Gleixner , Andy Shevchenko , Linux ARM , Juergen Gross , Thomas Bogendoerfer , Daniel Lezcano , linux-parisc@vger.kernel.org, Linux PM , Sebastian Reichel , Linux Kernel Mailing List , "K . C . Kuen-Chern Lin" , Palmer Dabbelt , Philipp Zabel , Guo Ren , Andrew Morton , linuxppc-dev , Joshua Thompson Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Nov 26, 2021 at 7:01 PM Dmitry Osipenko wrote: > > Add blocking_notifier_call_chain_is_empty() that returns true if call > chain is empty. > > Signed-off-by: Dmitry Osipenko > --- > include/linux/notifier.h | 2 ++ > kernel/notifier.c | 14 ++++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/include/linux/notifier.h b/include/linux/notifier.h > index 4b80a815b666..924c9d7c8e73 100644 > --- a/include/linux/notifier.h > +++ b/include/linux/notifier.h > @@ -173,6 +173,8 @@ int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh, > int raw_notifier_call_chain_robust(struct raw_notifier_head *nh, > unsigned long val_up, unsigned long val_down, void *v); > > +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh); > + > #define NOTIFY_DONE 0x0000 /* Don't care */ > #define NOTIFY_OK 0x0001 /* Suits me */ > #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ > diff --git a/kernel/notifier.c b/kernel/notifier.c > index b8251dc0bc0f..b20cb7b9b1f0 100644 > --- a/kernel/notifier.c > +++ b/kernel/notifier.c > @@ -322,6 +322,20 @@ int blocking_notifier_call_chain(struct blocking_notifier_head *nh, > } > EXPORT_SYMBOL_GPL(blocking_notifier_call_chain); > > +/** > + * blocking_notifier_call_chain_is_empty - Check whether notifier chain is empty > + * @nh: Pointer to head of the blocking notifier chain > + * > + * Checks whether notifier chain is empty. > + * > + * Returns true is notifier chain is empty, false otherwise. > + */ > +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh) > +{ > + return !rcu_access_pointer(nh->head); > +} > +EXPORT_SYMBOL_GPL(blocking_notifier_call_chain_is_empty); The check is not reliable (racy) without locking, so I wouldn't export anything like this to modules. At least IMO it should be added along with a user. From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Date: Fri, 10 Dec 2021 18:14:02 +0000 Subject: Re: [PATCH v4 02/25] notifier: Add blocking_notifier_call_chain_is_empty() Message-Id: List-Id: References: <20211126180101.27818-1-digetx@gmail.com> <20211126180101.27818-3-digetx@gmail.com> In-Reply-To: <20211126180101.27818-3-digetx@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Dmitry Osipenko Cc: Thierry Reding , Jonathan Hunter , Russell King , Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Sebastian Reichel , Linus Walleij , Philipp Zabel , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , the arch/x86 maintainers , "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , "Rafael J. Wysocki" , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , Pavel Machek , Lee Jones , Andrew Morton , Guenter Roeck , Daniel Lezcano , Andy Shevchenko , Ulf Hansson , alankao@andestech.com, "K . C . Kuen-Chern Lin" , Linux ARM , Linux Kernel Mailing List , linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev , linux-riscv@lists.infradead.org, Linux-sh list , xen-devel@lists.xenproject.org, ACPI Devel Maling List , Linux PM , linux-tegra On Fri, Nov 26, 2021 at 7:01 PM Dmitry Osipenko wrote: > > Add blocking_notifier_call_chain_is_empty() that returns true if call > chain is empty. > > Signed-off-by: Dmitry Osipenko > --- > include/linux/notifier.h | 2 ++ > kernel/notifier.c | 14 ++++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/include/linux/notifier.h b/include/linux/notifier.h > index 4b80a815b666..924c9d7c8e73 100644 > --- a/include/linux/notifier.h > +++ b/include/linux/notifier.h > @@ -173,6 +173,8 @@ int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh, > int raw_notifier_call_chain_robust(struct raw_notifier_head *nh, > unsigned long val_up, unsigned long val_down, void *v); > > +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh); > + > #define NOTIFY_DONE 0x0000 /* Don't care */ > #define NOTIFY_OK 0x0001 /* Suits me */ > #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ > diff --git a/kernel/notifier.c b/kernel/notifier.c > index b8251dc0bc0f..b20cb7b9b1f0 100644 > --- a/kernel/notifier.c > +++ b/kernel/notifier.c > @@ -322,6 +322,20 @@ int blocking_notifier_call_chain(struct blocking_notifier_head *nh, > } > EXPORT_SYMBOL_GPL(blocking_notifier_call_chain); > > +/** > + * blocking_notifier_call_chain_is_empty - Check whether notifier chain is empty > + * @nh: Pointer to head of the blocking notifier chain > + * > + * Checks whether notifier chain is empty. > + * > + * Returns true is notifier chain is empty, false otherwise. > + */ > +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh) > +{ > + return !rcu_access_pointer(nh->head); > +} > +EXPORT_SYMBOL_GPL(blocking_notifier_call_chain_is_empty); The check is not reliable (racy) without locking, so I wouldn't export anything like this to modules. At least IMO it should be added along with a user.