Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6347786iob; Tue, 10 May 2022 16:41:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO0m42R+KHst1B/WvMu0Wjfoq0lb3ufIANhPbWW1LcZqDFojKcapnwCzX/AyWTjklid1Ix X-Received: by 2002:a62:31c1:0:b0:50a:4909:2691 with SMTP id x184-20020a6231c1000000b0050a49092691mr22896432pfx.64.1652226101646; Tue, 10 May 2022 16:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652226101; cv=none; d=google.com; s=arc-20160816; b=AInVQfO8fPX4uwDJwQfiO6b0ZbA9nDhpp1u9HKfJSCXoPLpOnCj/ALmjH8n9Pvh1IM 5FKDZW+VgNDZRHkJMCLMQ4lWgubyUZxZUVz5Ow43akLI27cMsv853TjgyAIBuB6fZa2n uA46ZTyV0+D0t9Bie4tMtvqtWMpmYQMpHIYl23eBTMY5OIClOnI9L1/FJtdfwSa+BrN0 MiWduLo8bO+Lock0hsqMtN4Qk6oft0JSMlloLiPyGSmCL9LOq8XviGzV2bzgbnKgEMzn zCQ/eaQeRAQtlFMY+iy2mhbaDexWtYTFRWv0LtP8861/ttd26ZEsm3jbR2Mn5YYO/Z+w OQQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=jdgL2Y2w36JrFrG5RlWCgCNnWmQero910ailHPoTjkU=; b=1HDEa6jZvwCTFtquz5NWgBHdlvwfZtE3m7fYHP0LwizQAyZT9yedOzd0nF7PMa0nPJ Qvbq3EYvMDR3jC6s8mgh4SuHHkP2QkTVlFCBn0S1RP/MaaZwNmFPZy1++MKrlNVQ8s1h LQX/uNCvlLC5TMSZGW7+btrnnejzC51bhATtRVf8FC4rgxIFSDkHJcXLuFM82K38xtO4 fGzPpFv2kM0FT+jenHbRnO6/WrovJ2CVAWTOgNIDXCrdkqFTbTbNu+0Aa0QyYDrUk9J3 33KHv1mN1Gr9MX6p/0yraBMToa6SG37Z/UubsvHytn52EP3dgMjABWNs5bWtvktMEMcu ZLZw== ARC-Authentication-Results: i=1; mx.google.com; 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 y15-20020aa793cf000000b0050e01cd969dsi301797pff.244.2022.05.10.16.41.25; Tue, 10 May 2022 16:41:41 -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; 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 S1348819AbiEJSUN convert rfc822-to-8bit (ORCPT + 99 others); Tue, 10 May 2022 14:20:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348854AbiEJST0 (ORCPT ); Tue, 10 May 2022 14:19:26 -0400 Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 190252A975A; Tue, 10 May 2022 11:14:24 -0700 (PDT) Received: by mail-yb1-f174.google.com with SMTP id m128so32191961ybm.5; Tue, 10 May 2022 11:14:24 -0700 (PDT) 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:content-transfer-encoding; bh=qpqXrLDWUEHd+BUtmgMjhwAa3QcGPruT6uNMBEv9rjU=; b=sE0t+MrA2XaCL45MizPmFfYKh+U7rCzOjLv98vxpalwZsq4dz5KZYWa5EvT7z4Dj/J 72cDF6NlgQd5iWSoHTtTXxceYUf04R6uRHcOV8jsHXPlhwwbDMcx1IMyPtxOrsKhDggi wuvB1W8gNO5ex306dapgVyE0ASFzoomTxg7L9zcB+drqohTFQe1hR9PsfiRaJ27pJr9l H9JvOI63+Ooq4kqdLZBUXUvsOeixRzwIj1hEV+GcQckk7SAXqz9jSivd5ellFLiPqFs8 5bJ2n96C8IUu5Z4Fpv4clNCpiCIoJ0o2C6AAumEzIviiNN9HcMufo4dJXUAXqyc/StxF 2E1g== X-Gm-Message-State: AOAM531+oHyPotUKmUfvdnQsDixTSyf4gFm2u1Db2FoFEqVUEzAdkJOx yFppIfJjpin5xoQr9N1U5JMJQ0EWlcJyxNaNJzA= X-Received: by 2002:a25:e792:0:b0:645:7ddb:b5eb with SMTP id e140-20020a25e792000000b006457ddbb5ebmr19781278ybh.482.1652206451725; Tue, 10 May 2022 11:14:11 -0700 (PDT) MIME-Version: 1.0 References: <20220509233235.995021-1-dmitry.osipenko@collabora.com> <20220509233235.995021-2-dmitry.osipenko@collabora.com> In-Reply-To: <20220509233235.995021-2-dmitry.osipenko@collabora.com> From: "Rafael J. Wysocki" Date: Tue, 10 May 2022 20:14:00 +0200 Message-ID: Subject: Re: [PATCH v8 01/27] notifier: Add atomic_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 , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Linux Kernel Mailing List , linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, "open list:BROADCOM NVRAM DRIVER" , linux-parisc@vger.kernel.org, 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" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, 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 On Tue, May 10, 2022 at 1:33 AM Dmitry Osipenko wrote: > > Add atomic_notifier_call_chain_is_empty() that returns true if given > atomic call chain is empty. It would be good to mention a use case for it. > Reviewed-by: Michał Mirosław > Signed-off-by: Dmitry Osipenko > --- > include/linux/notifier.h | 2 ++ > kernel/notifier.c | 13 +++++++++++++ > 2 files changed, 15 insertions(+) > > diff --git a/include/linux/notifier.h b/include/linux/notifier.h > index 87069b8459af..95e2440037de 100644 > --- a/include/linux/notifier.h > +++ b/include/linux/notifier.h > @@ -173,6 +173,8 @@ extern int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh > extern int raw_notifier_call_chain_robust(struct raw_notifier_head *nh, > unsigned long val_up, unsigned long val_down, void *v); > > +extern bool atomic_notifier_call_chain_is_empty(struct atomic_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 ba005ebf4730..aaf5b56452a6 100644 > --- a/kernel/notifier.c > +++ b/kernel/notifier.c > @@ -204,6 +204,19 @@ int atomic_notifier_call_chain(struct atomic_notifier_head *nh, > EXPORT_SYMBOL_GPL(atomic_notifier_call_chain); > NOKPROBE_SYMBOL(atomic_notifier_call_chain); > > +/** > + * atomicnotifier_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 atomic_notifier_call_chain_is_empty(struct atomic_notifier_head *nh) > +{ > + return !rcu_access_pointer(nh->head); > +} > + > /* > * Blocking notifier chain routines. All access to the chain is > * synchronized by an rwsem. > -- > 2.35.1 >