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=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 D73DCC2D0E4 for ; Mon, 23 Nov 2020 23:22:12 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 4151920691 for ; Mon, 23 Nov 2020 23:22:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="vMZn5i+q"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="zpqpMZvc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4151920691 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=iArqMfLsk4f1FgS57NmSFqktBTHc3L+zZhNPR+fiYDU=; b=vMZn5i+qAm+6JcMUHP6+GT5YH XNzk/v+bfJuZF5AJbanrdsWINmtKD6jq1DOJgWTREHARLICssR28BsaAD0KiXnMO/bJTiOS3YACHb ssy0oc1BAba5mtUX5NjgXBA11Ixd/8ioH4LRl2ePglA4sjCtmDgtId2jrkVpqr6vxfpQEJRVff7qA e4z201qDXwH+gzWmBxMl+M8XKIJK3VzeUerJLsQa1qq0cUkfWGIP/sVNi4j6TUIiMiwDyReF0Yape /TscpZJNFfKeKQVUyYoO+Fk57aruDaTQWkdfhicVeXmRi/5lybkqsQR05rELKJQ3Aq2FlId+lQkUO amsFOYrpg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khL95-0007Fw-TK; Mon, 23 Nov 2020 23:21:19 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1khL8v-0007FA-Ow for linux-arm-kernel@lists.infradead.org; Mon, 23 Nov 2020 23:21:11 +0000 Received: from localhost (unknown [176.167.152.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4344320691; Mon, 23 Nov 2020 23:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606173668; bh=CKEZj+lJVWkeVVIkmbst5AlXQtm5TYqw8mkzx03cZBU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zpqpMZvcXj6eTZp/HvX7RSWVfU6lHF73DU+DFeuP40CbQiCiDOIg1/VNvpX1jv6cD Gt3rCu0U+kSHPlMbzN7C3jATvZXGSXHffUaym7cB38YrFwbHnTI/aFUVqHhsz/7SQE KtHgEJvoXzPT3SHCBdQxaAUJhf1EzU4WZWSzY7ac= Date: Tue, 24 Nov 2020 00:21:06 +0100 From: Frederic Weisbecker To: Alex Belits Subject: Re: [EXT] Re: [PATCH v5 9/9] task_isolation: kick_all_cpus_sync: don't kick isolated cpus Message-ID: <20201123232106.GD1751@lothringen> References: <8d887e59ca713726f4fcb25a316e1e932b02823e.camel@marvell.com> <3236b13f42679031960c5605be20664e90e75223.camel@marvell.com> <20201123222907.GC1751@lothringen> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201123_182110_060070_77F5C99C X-CRM114-Status: GOOD ( 25.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-arch@vger.kernel.org" , "nitesh@redhat.com" , "pauld@redhat.com" , "catalin.marinas@arm.com" , "peterz@infradead.org" , Prasun Kapoor , "mtosatti@redhat.com" , "linux-kernel@vger.kernel.org" , "rostedt@goodmis.org" , "davem@davemloft.net" , "leon@sidebranch.com" , "netdev@vger.kernel.org" , "peterx@redhat.com" , "trix@redhat.com" , "tglx@linutronix.de" , "linux-api@vger.kernel.org" , "will@kernel.org" , "mingo@kernel.org" , "linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Nov 23, 2020 at 10:39:34PM +0000, Alex Belits wrote: > > On Mon, 2020-11-23 at 23:29 +0100, Frederic Weisbecker wrote: > > External Email > > > > ------------------------------------------------------------------- > > --- > > On Mon, Nov 23, 2020 at 05:58:42PM +0000, Alex Belits wrote: > > > From: Yuri Norov > > > > > > Make sure that kick_all_cpus_sync() does not call CPUs that are > > > running > > > isolated tasks. > > > > > > Signed-off-by: Yuri Norov > > > [abelits@marvell.com: use safe task_isolation_cpumask() > > > implementation] > > > Signed-off-by: Alex Belits > > > --- > > > kernel/smp.c | 14 +++++++++++++- > > > 1 file changed, 13 insertions(+), 1 deletion(-) > > > > > > diff --git a/kernel/smp.c b/kernel/smp.c > > > index 4d17501433be..b2faecf58ed0 100644 > > > --- a/kernel/smp.c > > > +++ b/kernel/smp.c > > > @@ -932,9 +932,21 @@ static void do_nothing(void *unused) > > > */ > > > void kick_all_cpus_sync(void) > > > { > > > + struct cpumask mask; > > > + > > > /* Make sure the change is visible before we kick the cpus */ > > > smp_mb(); > > > - smp_call_function(do_nothing, NULL, 1); > > > + > > > + preempt_disable(); > > > +#ifdef CONFIG_TASK_ISOLATION > > > + cpumask_clear(&mask); > > > + task_isolation_cpumask(&mask); > > > + cpumask_complement(&mask, &mask); > > > +#else > > > + cpumask_setall(&mask); > > > +#endif > > > + smp_call_function_many(&mask, do_nothing, NULL, 1); > > > + preempt_enable(); > > > > Same comment about IPIs here. > > This is different from timers. The original design was based on the > idea that every CPU should be able to enter kernel at any time and run > kernel code with no additional preparation. Then the only solution is > to always do full broadcast and require all CPUs to process it. > > What I am trying to introduce is the idea of CPU that is not likely to > run kernel code any soon, and can afford to go through an additional > synchronization procedure on the next entry into kernel. The > synchronization is not skipped, it simply happens later, early in > kernel entry code. Ah I see, this is ordered that way: ll_isol_flags = ISOLATED CPU 0 CPU 1 ------------------ ----------------- // kernel entry data_to_sync = 1 ll_isol_flags = ISOLATED_BROKEN smp_mb() smp_mb() if ll_isol_flags(CPU 1) == ISOLATED READ data_to_sync smp_call(CPU 1) You should document that, ie: explain why what you're doing is safe. Also Beware though that the data to sync in question doesn't need to be visible in the entry code before task_isolation_kernel_enter(). You need to audit all the callers of kick_all_cpus_sync(). _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel