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 X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 285AAC76190 for ; Mon, 22 Jul 2019 18:52:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 071D221955 for ; Mon, 22 Jul 2019 18:52:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731844AbfGVSwI (ORCPT ); Mon, 22 Jul 2019 14:52:08 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:38014 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727821AbfGVSwI (ORCPT ); Mon, 22 Jul 2019 14:52:08 -0400 Received: from pd9ef1cb8.dip0.t-ipconnect.de ([217.239.28.184] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hpdPk-0002FA-Kc; Mon, 22 Jul 2019 20:52:00 +0200 Date: Mon, 22 Jul 2019 20:51:59 +0200 (CEST) From: Thomas Gleixner To: Nadav Amit cc: Peter Zijlstra , Andy Lutomirski , Dave Hansen , the arch/x86 maintainers , LKML , Ingo Molnar , Rik van Riel , Josh Poimboeuf Subject: Re: [PATCH v3 1/9] smp: Run functions concurrently in smp_call_function_many() In-Reply-To: <91940019-826C-4F33-904B-0767D95A5E21@vmware.com> Message-ID: References: <20190719005837.4150-1-namit@vmware.com> <20190719005837.4150-2-namit@vmware.com> <20190722182159.GB6698@worktop.programming.kicks-ass.net> <91940019-826C-4F33-904B-0767D95A5E21@vmware.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1903360966-1563821520=:1659" X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1903360966-1563821520=:1659 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Mon, 22 Jul 2019, Nadav Amit wrote: > > On Jul 22, 2019, at 11:37 AM, Thomas Gleixner wrote: > > > > On Mon, 22 Jul 2019, Peter Zijlstra wrote: > > > >> On Thu, Jul 18, 2019 at 05:58:29PM -0700, Nadav Amit wrote: > >>> +/* > >>> + * Call a function on all processors. May be used during early boot while > >>> + * early_boot_irqs_disabled is set. > >>> + */ > >>> +static inline void on_each_cpu(smp_call_func_t func, void *info, int wait) > >>> +{ > >>> + on_each_cpu_mask(cpu_online_mask, func, info, wait); > >>> +} > >> > >> I'm thinking that one if buggy, nothing protects online mask here. > > > > The current implementation has preemption disabled before touching > > cpu_online_mask which at least protects against a CPU going away as that > > prevents the stomp machine thread from getting on the CPU. But it's not > > protected against a CPU coming online concurrently. > > I still don’t understand. If you called cpu_online_mask() and did not > disable preemption before calling it, you are already (today) not protected > against another CPU coming online. Disabling preemption in on_each_cpu() > will not solve it. Disabling preemption _cannot_ protect against a CPU coming online. It only can protect against a CPU being offlined. The current implementation of on_each_cpu() disables preemption _before_ touching cpu_online_mask. void on_each_cpu(void (*func) (void *info), void *info, int wait) { unsigned long flags; preempt_disable(); smp_call_function(func, info, wait); smp_call_function() has another preempt_disable as it can be called separately and it does: preempt_disable(); smp_call_function_many(cpu_online_mask, func, info, wait); Your new on_each_cpu() implementation does not. So there is a difference. Whether it matters or not is a different question, but that needs to be explained and documented. Thanks, tglx --8323329-1903360966-1563821520=:1659--