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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C2CDC433F5 for ; Wed, 27 Oct 2021 22:55:17 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C318F60F92 for ; Wed, 27 Oct 2021 22:55:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C318F60F92 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4HfkYH3MM3z3dlh for ; Thu, 28 Oct 2021 09:55:15 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=BbS8+/zx; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::134; helo=mail-lf1-x134.google.com; envelope-from=digetx@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=BbS8+/zx; dkim-atps=neutral Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (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 4HfhP90mNMz2xXs; Thu, 28 Oct 2021 08:18:05 +1100 (AEDT) Received: by mail-lf1-x134.google.com with SMTP id bi35so8956098lfb.9; Wed, 27 Oct 2021 14:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O+IvQoJf2OjzCPAk90L+IlIvsTQGqRsS8A3mVG9thss=; b=BbS8+/zxVJ00rr3ixtYTd3bTdxqjkUjnBr55DaOxzJArvyNX4521PAqPigYX/BjB1N aGylVDFiYrs5wRaWuZx6L52it/PPywema7yDnahBHenwiuFnc4S3m//ivsOGtXuUlPNB ubXOhenNVEu1KXB2mXMptIWVwaeJRf3hxW3c8R68HPPg3pjoH3MM7xhUxuphpty83aFx DGHamMHIXY7/zgP3wsKkRhZ7yEHgmahY/byikn8BiZjEw2DWUQkjcB5nYo+Xgh+eH8p4 oVpJycq4ZWi1GYj36y1/HBYlXfcjUxN5WpbpwFTT0cF/PRko7dGul5P66XpFeKCAINSY 8XVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O+IvQoJf2OjzCPAk90L+IlIvsTQGqRsS8A3mVG9thss=; b=hbxORGkR5dsSPISY5QH8p9HcFT+sqqHsvxTsvxODXzyFSrehJRvQFuKdsU1DBm3Zng gyeHxzaanEv9vHFTe8H3Q7hoXUeM58UD9sDQDMOi7kGaMR2hcFRpmV3Wi+MifDP57O49 BYJewx5kUO2OIIF5UGIshtW6hSylE7mpcIeDnkCplqiCaJI12h1jHHzLbTkArbc45rW9 LeB2YgoGCQxBDMLJQj+J6Kj765rxeBFO0y7fh4VQ8Z6nDKxZZWwQMQmx6WAb1hydWdNY C1sgk3HqD6dntw8SYHelg8l9I3gVo7a7EW8Cz5HVg/aUEbrLCNPvlvQQRZjzez9vt2/I CiLg== X-Gm-Message-State: AOAM5329+MO030bQgwyKQPMx5vj1D3z+8QnVXEdoZKj6+RtE6eHOtvW0 HQzRi1ElDR5MjDD/OQupxSA= X-Google-Smtp-Source: ABdhPJxyJaCNELbykyJ8mI+u0lU4wtjMFWua0Lm4EEmjlSiKb32hiTjDEQ+OHhGC/feOlGuy6qCfSA== X-Received: by 2002:ac2:4285:: with SMTP id m5mr140041lfh.86.1635369481970; Wed, 27 Oct 2021 14:18:01 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:01 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Subject: [PATCH v2 05/45] reboot: Warn if restart handler has duplicated priority Date: Thu, 28 Oct 2021 00:16:35 +0300 Message-Id: <20211027211715.12671-6-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Thu, 28 Oct 2021 09:51: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: Rich Felker , linux-ia64@vger.kernel.org, Tomer Maimon , Santosh Shilimkar , linux-sh@vger.kernel.org, Boris Ostrovsky , Linus Walleij , Dave Hansen , linux-acpi@vger.kernel.org, Tali Perry , "James E.J. Bottomley" , Paul Mackerras , Pavel Machek , "H. Peter Anvin" , linux-riscv@lists.infradead.org, Vincent Chen , Will Deacon , Greg Ungerer , Stefano Stabellini , Benjamin Fair , Yoshinori Sato , Krzysztof Kozlowski , Helge Deller , x86@kernel.org, linux-csky@vger.kernel.org, Tony Lindgren , Chen-Yu Tsai , Ingo Molnar , Geert Uytterhoeven , Catalin Marinas , xen-devel@lists.xenproject.org, linux-mips@vger.kernel.org, Len Brown , Albert Ou , linux-pm@vger.kernel.org, =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= , Vladimir Zapolskiy , linux-m68k@lists.linux-m68k.org, Borislav Petkov , Greentime Hu , Paul Walmsley , linux-tegra@vger.kernel.org, Thomas Gleixner , linux-omap@vger.kernel.org, Nancy Yuen , linux-arm-kernel@lists.infradead.org, Juergen Gross , Thomas Bogendoerfer , linux-parisc@vger.kernel.org, Nick Hu , Avi Fishman , Patrick Venture , Liam Girdwood , linux-kernel@vger.kernel.org, Palmer Dabbelt , Philipp Zabel , Guo Ren , linuxppc-dev@lists.ozlabs.org, openbmc@lists.ozlabs.org, Joshua Thompson Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Add sanity check which ensures that there are no two restart handlers registered with the same priority. Normally it's a direct sign of a problem if two handlers use the same priority. Signed-off-by: Dmitry Osipenko --- kernel/reboot.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kernel/reboot.c b/kernel/reboot.c index efb40d095d1e..d39e599c3c99 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -182,7 +182,20 @@ static ATOMIC_NOTIFIER_HEAD(restart_handler_list); */ int register_restart_handler(struct notifier_block *nb) { - return atomic_notifier_chain_register(&restart_handler_list, nb); + int ret; + + ret = atomic_notifier_chain_register(&restart_handler_list, nb); + if (ret) + return ret; + + /* + * Handler must have unique priority. Otherwise invocation order is + * determined by the registration order, which is presumed to be + * unreliable. + */ + WARN_ON(!atomic_notifier_has_unique_priority(&restart_handler_list, nb)); + + return 0; } EXPORT_SYMBOL(register_restart_handler); -- 2.33.1