Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2036425iob; Thu, 19 May 2022 23:38:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzT5BBk8Apz+BECTCFipHAIO4Cu4FOIm8+bN02eQr8iBKarT1c4QZq9f5gWj7MOIphffF9W X-Received: by 2002:a17:90a:4b0c:b0:1df:112:fe49 with SMTP id g12-20020a17090a4b0c00b001df0112fe49mr9313225pjh.155.1653028718961; Thu, 19 May 2022 23:38:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653028718; cv=none; d=google.com; s=arc-20160816; b=fC7xErilRQXeyMYndx5ihJ/maHCbRHBMDnVEmbtPJ3TjrlO5ec1HTsLx5Fv32GzDi4 p/ujOt/4V9jF0zIoBVGxMSZsOp7WMAl+k6qGmZJXx3kVz94kuaJ44oN/O+JwyyQFSMZx LM4bUL7BTR0rzFM7YustnsT7/S6vZ5630oYoiTpIBpmfxO+8wejt2ia/MlHDdUv5mIXA fLQtCYwQntXZu9pXYvENGFSu1Z0P1enbTTRS2MUK7sMVs9dVPJaVC0lb0ZdrGJTcsU2o LvN95sbrvatXS0qRXtzLJkz5Yjd9q98YCqwec/6jH+JNhFoofBEFzUfJKLUJeM5kdIi9 TUjg== 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=w+OLnanoRgaAji3I8dPg2smuKSACWCAE+Te4D5oY3io=; b=rGx2wOz/+UGJs4xzmh93DRsWdX6NP9hIZwm0pY0D4T3YOF5bNVKpRtejRp+hVBKnkV QLisPl5v6TX6vg4xrUM/b6MEaQWv/kU2BUOt5UZoqKOO4DjTv5+aeQSXWeQMFhNkYK6Q Mro5uvD+acsDZNzbf62q6vU0/rgBK7kP512CXwEoWEithLDI0TSB6j0qSRr1mP8gLhbZ WeyZR951h4UPfeZM2NiG8w9BLebvND+ivO1xBU831Hlz/3WbNaS+UuMCx2N3e+VBqOYb Vj8nII/l85YGkQ3CPLbf2UxGg49yOqUYgo3BcEFHo4orPWHaOsUcX2Mzi/L95g9UugLG TNZg== 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 v22-20020a636116000000b003995aee3634si9349699pgb.175.2022.05.19.23.38.25; Thu, 19 May 2022 23:38:38 -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 S240410AbiESR23 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 19 May 2022 13:28:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243067AbiESR0Q (ORCPT ); Thu, 19 May 2022 13:26:16 -0400 Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB4F83E5C0 for ; Thu, 19 May 2022 10:25:56 -0700 (PDT) Received: by mail-yb1-f179.google.com with SMTP id e78so10159465ybc.12 for ; Thu, 19 May 2022 10:25:56 -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=1p7cU7b8qz6i860wpR3X62w6Sx8yiR8QDIbRQYHlwIQ=; b=Prd/HQPFlhvog7ZVm5mppKaI114CCscEukhbV9IcZZZsHxSvz8KFzKqvPiUjSHxq3O qtfUiD6ceGVfXiOjqIvdDddnsrkzVrmVlv3YyIW6XXYU2QLlowdM1Mdlo3F5biIpjf+r HrTV4+bCD/A3fbS8LD263tiATnP+t/20njIP5sQzeBn9e1okO4zKJ/hHZmOWFa0SOm+L Pg40nBLva/2x/G9zMN0rCgg06fhpXTZSvfAs/XA+9mkx2nOMw8hBH7A2hHYdOsiId+kv DFjn+3kn27NH/Lds9IgRzoKHMl26IqfKsifWcqbuiWfq+jxcsbLgPIqBaI7UEm2csk+R aeVA== X-Gm-Message-State: AOAM53175m5+3pfgykJhCq8A+8SNZA8WPI4VNtXw/NQ+QT4ejV+j1uti sALYJf+kvrx3YtnphkRYKlVbzzcV8t+1qq0t18k= X-Received: by 2002:a25:d687:0:b0:64e:3a41:8d5 with SMTP id n129-20020a25d687000000b0064e3a4108d5mr5431430ybg.622.1652981155848; Thu, 19 May 2022 10:25:55 -0700 (PDT) MIME-Version: 1.0 References: <20220519110232.1198823-1-dmitry.osipenko@collabora.com> In-Reply-To: <20220519110232.1198823-1-dmitry.osipenko@collabora.com> From: "Rafael J. Wysocki" Date: Thu, 19 May 2022 19:25:45 +0200 Message-ID: Subject: Re: [PATCH v10] notifier: Add atomic_notifier_call_chain_is_empty() To: Dmitry Osipenko Cc: "Rafael J . Wysocki" , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Linux Kernel Mailing List 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 Thu, May 19, 2022 at 1:02 PM Dmitry Osipenko wrote: > > Add atomic_notifier_call_chain_is_empty() that returns true if given > atomic call chain is empty. > > The first user of this new notifier API function will be the kernel > power-off core code that will support power-off call chains. The core > code will need to check whether there is a power-off handler registered > at all in order to decide whether to halt machine or power it off. > > Reviewed-by: Michał Mirosław > Signed-off-by: Dmitry Osipenko > --- > > Changelog: > > v10: - Corrected another doc-comment typo s/atomicnotifier/atomic_notifier/. > > v9: - Extended commit message with a usage example. > > - Corrected doc-comment with s/blocking/atomic/. > > 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..137b902c985b 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); > > +/** > + * atomic_notifier_call_chain_is_empty - Check whether notifier chain is empty > + * @nh: Pointer to head of the atomic 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. > -- Applied as 5.19 material, thanks!