Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2527730pxb; Mon, 18 Apr 2022 02:26:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPIXZkZVFdVMI/zQKOFz4vcXCTOz/055cvLMOEcHR52J4Fr3BjWZHeVOwsf+ZYcjVnaTSh X-Received: by 2002:a50:9e61:0:b0:419:d8e5:6236 with SMTP id z88-20020a509e61000000b00419d8e56236mr11124996ede.327.1650273967073; Mon, 18 Apr 2022 02:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650273967; cv=none; d=google.com; s=arc-20160816; b=BAdZ2jr2/i4pFu3IG/2yr1V/VJ8zQH1w1cN3lhioPa9DzqbnaCpN7XXmVQ0D6fM829 quG1oa6uxeAkR+Urs5fs7SvK1x8THsQcmyVdyQBZ4iI//S7llqb2T+XlYSzUa1Q/RN1/ m2hpjbWZ0miDXlDD9EaoAnm/LsZGMLLkRQwitJ+kraNuXa9yvYFQTURcmOM26Ue9N/gA itwp6z6bEHdEhSHyYdAkmcL5SRdDuhSOi6DQ5SH6bsVs0xig3Fkl3b31jHzUtH0pIfBj N20QJPawUvoHAhTlMB+OhHR9cnU3i8r1nfXv4O/DxI68Jkl6wEOuRmOmIJSMkLWrHDFb norA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=56fYIdXTDpQn1zCvPaKTS6jQYgIYkfmfZjm1mkWeNuk=; b=PruwiLyYyoAUsLR3AzGVDpQcy8Xawc0LRWvEoHZbZW8v0+dvftHlaubYsbvjrvOCi9 YlNvrUhxMXakyhkM/Tc9cyasbLtxZPmzSUVw14kpv2c/p4jR6aWBZksNUqSG3Mi+DYMr rzDH+PChD036hyJZFWMO4Pc8K1Kn8JZd6rMNlRfgpUDxPozzJyvf96oiUbOdmM5rJL8i IiMLSoagPjLDITS+fsJRuUJbR4zIzWUk7tsYDbUpF6uM4VLO2wavXqiCu68xKLnmTYBd gfYKTd/ERlnqWhcjv4hXx8TyDnCjaPkSh77K6uZTLHv0J0R0ZqQ2KorfUtpOEPs4700m eTIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=H6wbrzdv; 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=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h1-20020a056402280100b0041d85852a22si6961918ede.190.2022.04.18.02.25.43; Mon, 18 Apr 2022 02:26:07 -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; dkim=pass header.i=@collabora.com header.s=mail header.b=H6wbrzdv; 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235579AbiDRBcV (ORCPT + 99 others); Sun, 17 Apr 2022 21:32:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232905AbiDRBcR (ORCPT ); Sun, 17 Apr 2022 21:32:17 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDFBB17068; Sun, 17 Apr 2022 18:29:38 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 77A9B1F44320 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1650245376; bh=Ajn7d9ehxuO5NknWvmo0k/aIhgzNt/YPk9MMAC0rgK4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=H6wbrzdvBv8/q0QMxBBTynYiA8MocDKNi6pPzdbeah1TBS0sfobjoYMeVHdywDKJa YOMseWFehs7fKiS1bqLxpLaRV3E2gVJ6NGmAk/kK7Tkj7SOk+d7kIA+pVboML+0znZ oBB6ZdZaJe8q4CuDbVjC8i5gSLP4M7dhUJeJhWywSpYx0y55HsGlo0NSg/sn82x813 XAZwVlD5NoEcUOWKl8ezQsrDqxJrPlOK3xiszEQs//fITbMqaQ95IAUW03Xr4Fzay/ IWbATXa2Chl0Jy2VqKMQd994g2oQEgzNvPwVOvB9VgKGF8p+Y8PjFoazCNalTfgpXO TGCe7ZBTJXzKg== Message-ID: Date: Mon, 18 Apr 2022 04:29:30 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v7 03/20] reboot: Print error message if restart handler has duplicated priority Content-Language: en-US To: "Rafael J. Wysocki" 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 , 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 References: <20220411233832.391817-1-dmitry.osipenko@collabora.com> <20220411233832.391817-4-dmitry.osipenko@collabora.com> From: Dmitry Osipenko In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham 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 4/14/22 14:19, Rafael J. Wysocki wrote: > On Thu, Apr 14, 2022 at 12:24 AM Dmitry Osipenko > wrote: >> >> On 4/13/22 21:48, Rafael J. Wysocki wrote: >>> On Tue, Apr 12, 2022 at 1:39 AM Dmitry Osipenko >>> wrote: >>>> >>>> Add sanity check which ensures that there are no two restart handlers >>>> registered using the same priority. This requirement will become mandatory >>>> once all drivers will be converted to the new API and such errors will be >>>> fixed. >>>> >>>> Signed-off-by: Dmitry Osipenko >>> >>> The first two patches in the series are fine with me and there's only >>> one minor nit regarding this one (below). >>> >>>> --- >>>> kernel/reboot.c | 15 +++++++++++++++ >>>> 1 file changed, 15 insertions(+) >>>> >>>> diff --git a/kernel/reboot.c b/kernel/reboot.c >>>> index ed4e6dfb7d44..acdae4e95061 100644 >>>> --- a/kernel/reboot.c >>>> +++ b/kernel/reboot.c >>>> @@ -182,6 +182,21 @@ static ATOMIC_NOTIFIER_HEAD(restart_handler_list); >>>> */ >>>> int register_restart_handler(struct notifier_block *nb) >>>> { >>>> + int ret; >>>> + >>>> + ret = atomic_notifier_chain_register_unique_prio(&restart_handler_list, nb); >>>> + if (ret != -EBUSY) >>>> + return ret; >>>> + >>>> + /* >>>> + * Handler must have unique priority. Otherwise call order is >>>> + * determined by registration order, which is unreliable. >>>> + * >>>> + * This requirement will become mandatory once all drivers >>>> + * will be converted to use new sys-off API. >>>> + */ >>>> + pr_err("failed to register restart handler using unique priority\n"); >>> >>> I would use pr_info() here, because this is not a substantial error AFAICS. >> >> It's indeed not a substantial error so far, but it will become >> substantial later on once only unique priorities will be allowed. The >> pr_warn() could be a good compromise here, pr_info() is too mild, IMO. > > Well, I'm still unconvinced about requiring all of the users of this > interface to use unique priorities. > > Arguably, there are some of them who don't really care about the > ordering, so could there be an option for them to specify the lack of > care by, say, passing 0 as the priority that would be regarded as a > special case? > > IOW, if you pass 0, you'll be run along the others who've also passed > 0, but if you pass anything different from 0, it must be unique. What > do you think? There are indeed cases where ordering is unimportant. Like a case of PMIC and watchdog restart handlers for example, both handlers will produce equal effect from a user's perspective. Perhaps indeed it's more practical to have at least one shared level. In this patchset the level 0 is specified as an alias to the default level 128. If one user registers handler using unique level 128 and the other user uses non-unique level 0, then we have ambiguity. One potential option is to make the whole default level 128 non-unique. This will allow users to not care about the uniqueness by default like they always did it previously, but it will hide potential problems for users who actually need unique level and don't know about it yet due to a lucky registration ordering that they have today. Are you okay with this option?