From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Osipenko Date: Fri, 10 Dec 2021 20:16:29 +0000 Subject: Re: [PATCH v4 03/25] notifier: Add atomic/blocking_notifier_has_unique_priority() Message-Id: <218e67e2-1d8c-5727-3862-8884d74aa63e@gmail.com> List-Id: References: <20211126180101.27818-1-digetx@gmail.com> <20211126180101.27818-4-digetx@gmail.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 , 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 10.12.2021 22:33, Dmitry Osipenko пишет: >> Not really, they only prevent the race from occurring while >> notifier_has_unique_priority() is running. >> >> If anyone depends on this check for correctness, they need to lock the >> rwsem, do the check, do the thing depending on the check while holding >> the rwsem and then release the rwsem. Otherwise it is racy. >> > It's fine that it's a bit "racy" since in the context of this series. We > always do the check after adding new entry, so it's not a problem. > > There are two options: > > 1. Use blocking_notifier_has_unique_priority() like it's done in this > patchset. Remove it after all drivers are converted to the new API and > add blocking_notifier_chain_register_unique(). > > 2. Add blocking_notifier_chain_register_unique(), but don't let it fail > the registration of non-unique entries until all drivers are converted > to the new API. There is third, perhaps the best option: 3. Add blocking_notifier_chain_register_unique() and fall back to blocking_notifier_chain_register() if unique fails, do it until all drivers are converted to the new API.