Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp806430ybh; Tue, 21 Jul 2020 08:20:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7+pueRPPR18lTuFgX2wOgcUnLY259Bo66lK79znHIdiPmDAm3CyuzPTBn6LA2LAuMEVXs X-Received: by 2002:a17:906:aad7:: with SMTP id kt23mr27086099ejb.313.1595344841909; Tue, 21 Jul 2020 08:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595344841; cv=none; d=google.com; s=arc-20160816; b=blqQUV3lVrqTQyM/J+4zqfiFyE62rogxVKhA2XfBw9XduZFJkbpcyAIfs6zpN33Mtt k9k2TdqM2IEwyOGoZg8k8ECUtwdMeGLTXpRybpEBvOLX2lTxByxj158l9fiqWECo1Sgx 0h2l45MQrlghMTbdZ5L5zl+cNN0SNaqm+DUvKbOyuGo+QmZdbeVmU8pRDHNp+hIre+Ww 4LaAIHQ6q5RBp+AhFz/j5/xUGpconN3P9zdqNER2MD5NcZHFec7gRNKXDKgkPxWYPrIU xxwVRavl82tDLP4IFZYpw05IEeYaJsqQgc27K1URUfTmh1Pb7uolQ8AfQOHsAugzMFPi 4TlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=UDgd79BY7gi8TqLDKkueThe0INr/de8/XZtWeBtTp4g=; b=sVt2MqXlOzfko4d3Vf06JL8H+FjNFFcMX7L3DoO+BS/FQHnfEp6RPrd/lHudSqkZgy f2CJ78swCNr4ryacYaxvnNEQdau3f/GvdJSuHBzxvtG6fBfmBoRF4JhuqJZ6Jp0Q31MH vbI5IQoYpJeIm1aysquZBgLBbewQRqbNhXhG2tpLVZCDY29L9JJ91Dys8X6MZD5i3kGc dMBVQjipZPf+y+U0KE0OgyJGAJ1Htk9qA7uLvC5esOGJH0wnUe8DMX40eN1ejzbN+d5l Yi0GUic1JmYD+tzpbsf6SsKMDNeM/YAeC/joPlbcP6Xv/3qDOIhXOHWmm88mOeJopkL4 5yXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=1IvOQ6YE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a8si14253546ejx.45.2020.07.21.08.20.18; Tue, 21 Jul 2020 08:20:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=1IvOQ6YE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729746AbgGUPT7 (ORCPT + 99 others); Tue, 21 Jul 2020 11:19:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726522AbgGUPT7 (ORCPT ); Tue, 21 Jul 2020 11:19:59 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EA15C061794; Tue, 21 Jul 2020 08:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=UDgd79BY7gi8TqLDKkueThe0INr/de8/XZtWeBtTp4g=; b=1IvOQ6YEO1bgDDlBTYlRghsRlv x6BMvXrA/+9IbLHFeVn36I4gukr3Bn0cCKAe98VNUIWChuL16bJjc/bd3hPXxAasHTAKthuU/Zi1L A6hgB1abgU+vFB7TWrZ/bSs2B7H8p8oL09ta8vegyhRMyjcQXB2NF24/OxAecpjm5PhtPH9d3PR4X 8UhJ8Ag99fmvxPY0yXuOIz5+pu46/IdKlobtn7BI2JJUx27uO6IU0a6x+1Z133R8gYvanTD7wecUQ ctczp/CH/WNRGibFW3GSKRLnVLScFDieEdSKBYR2C2N3yfCzMq4p8WGmHOzqQ5neJE9D6AZLrz0aK mAmEF/5g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxu3Z-0001Uy-MG; Tue, 21 Jul 2020 15:19:49 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 76765301AC6; Tue, 21 Jul 2020 17:19:47 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 691E220107F23; Tue, 21 Jul 2020 17:19:47 +0200 (CEST) Date: Tue, 21 Jul 2020 17:19:47 +0200 From: Peter Zijlstra To: Mathieu Desnoyers Cc: Nicholas Piggin , Anton Blanchard , Arnd Bergmann , Jens Axboe , linux-arch , linux-kernel , linux-mm , linuxppc-dev , Andy Lutomirski , Andy Lutomirski , x86 Subject: Re: [RFC PATCH 4/7] x86: use exit_lazy_tlb rather than membarrier_mm_sync_core_before_usermode Message-ID: <20200721151947.GD10769@hirez.programming.kicks-ass.net> References: <1594868476.6k5kvx8684.astroid@bobo.none> <20200716110038.GA119549@hirez.programming.kicks-ass.net> <1594906688.ikv6r4gznx.astroid@bobo.none> <1314561373.18530.1594993363050.JavaMail.zimbra@efficios.com> <1595213677.kxru89dqy2.astroid@bobo.none> <2055788870.20749.1595263590675.JavaMail.zimbra@efficios.com> <1595324577.x3bf55tpgu.astroid@bobo.none> <20200721150656.GN119549@hirez.programming.kicks-ass.net> <616209816.22376.1595344513051.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <616209816.22376.1595344513051.JavaMail.zimbra@efficios.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 21, 2020 at 11:15:13AM -0400, Mathieu Desnoyers wrote: > ----- On Jul 21, 2020, at 11:06 AM, Peter Zijlstra peterz@infradead.org wrote: > > > On Tue, Jul 21, 2020 at 08:04:27PM +1000, Nicholas Piggin wrote: > > > >> That being said, the x86 sync core gap that I imagined could be fixed > >> by changing to rq->curr == rq->idle test does not actually exist because > >> the global membarrier does not have a sync core option. So fixing the > >> exit_lazy_tlb points that this series does *should* fix that. So > >> PF_KTHREAD may be less problematic than I thought from implementation > >> point of view, only semantics. > > > > So I've been trying to figure out where that PF_KTHREAD comes from, > > commit 227a4aadc75b ("sched/membarrier: Fix p->mm->membarrier_state racy > > load") changed 'p->mm' to '!(p->flags & PF_KTHREAD)'. > > > > So the first version: > > > > https://lkml.kernel.org/r/20190906031300.1647-5-mathieu.desnoyers@efficios.com > > > > appears to unconditionally send the IPI and checks p->mm in the IPI > > context, but then v2: > > > > https://lkml.kernel.org/r/20190908134909.12389-1-mathieu.desnoyers@efficios.com > > > > has the current code. But I've been unable to find the reason the > > 'p->mm' test changed into '!(p->flags & PF_KTHREAD)'. > > Looking back at my inbox, it seems like you are the one who proposed to > skip all kthreads: > > https://lkml.kernel.org/r/20190904124333.GQ2332@hirez.programming.kicks-ass.net I had a feeling it might've been me ;-) I just couldn't find the email. > > The comment doesn't really help either; sure we have the whole lazy mm > > thing, but that's ->active_mm, not ->mm. > > > > Possibly it is because {,un}use_mm() do not have sufficient barriers to > > make the remote p->mm test work? Or were we over-eager with the !p->mm > > doesn't imply kthread 'cleanups' at the time? > > The nice thing about adding back kthreads to the threads considered for membarrier > IPI is that it has no observable effect on the user-space ABI. No pre-existing kthread > rely on this, and we just provide an additional guarantee for future kthread > implementations. > > > Also, I just realized, I still have a fix for use_mm() now > > kthread_use_mm() that seems to have been lost. > > I suspect we need to at least document the memory barriers in kthread_use_mm and > kthread_unuse_mm to state that they are required by membarrier if we want to > ipi kthreads as well. Right, so going by that email you found it was mostly a case of being lazy, but yes, if we audit the kthread_{,un}use_mm() barriers and add any other bits that might be needed, covering kthreads should be possible. No objections from me for making it so.