Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp294660pxu; Tue, 1 Dec 2020 11:26:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxn9rbcbIKssChz0PiirsANu1SEg4h8anIV1BT4chjUMmm156uNsdkrbVqqhceNLFuRlQmQ X-Received: by 2002:a17:906:4698:: with SMTP id a24mr4654014ejr.90.1606850768574; Tue, 01 Dec 2020 11:26:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606850768; cv=none; d=google.com; s=arc-20160816; b=Hl7Qk41QCgku6ntHQe9DXMb5FJtPkJsTZKIniTwuN+qORhoHjC/DKuTZ3ip48sIRtu 15uVZD5Kv2yUWZSD3F3EbiaBvGwZuCQAH3MPalszYIJXMD0Qz2d4YtybdWWyjX+Cku83 wAbEwfzzoP2ieDsR+OB2mioo67aSrYNhhlRbFcNcea4UAWzWnlA2lSU8kP6/h61h7rw4 wwvioXXgw+j2ALklQR31SiHCSoMv4+KFMoF33OB/YUoS8G47ztykULz1ZnNWTHKNN7Xt 3HzIKDbx5DfCD3VVxSoq+Kg76UIWILTq3M7Y+Ce/OSJBWxfNLbwqMKPlMnhJ5ci682Cr QvlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7JLyHZJtRdTTbCdr1AWpBIMP6N5KB46ClouAigDfKUM=; b=R5JD3M1VaBQAGu/HCEuYqXrQAn47EdFH5Vs7rSys0nEBYvcJrGhA0RcDa9sxsLVGBx RjR9kdAw/CgAg+GrmvH+rbtRBk92ldWI7sK2eqpRHtdCrZTFjnHYXtyz9sGHS9GcQiJP qzCiTbUq6qn23NcQVE5z4bWx22zuTmBify5sY7QUac9VfP55265YbIGLDmKiMaXDW3eZ y+f4+xDv8yL3PhKI6owfP9BA/UnPNqLYg3lUmyc2uq3nlOSNkRniXcGC06QzNw0ztidY JGGzZ1rf9zIU6dLYu5TtIrtJxsZQ9V6deLiCrK92K1aQiJCrOOjfdEWXwdj60PuV1OaB r3IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=Zi0+mLPZ; 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 zc8si489149ejb.662.2020.12.01.11.25.45; Tue, 01 Dec 2020 11:26:08 -0800 (PST) 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=pass header.i=@infradead.org header.s=merlin.20170209 header.b=Zi0+mLPZ; 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 S1731278AbgLATWf (ORCPT + 99 others); Tue, 1 Dec 2020 14:22:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727431AbgLATWe (ORCPT ); Tue, 1 Dec 2020 14:22:34 -0500 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F983C0613CF for ; Tue, 1 Dec 2020 11:21:54 -0800 (PST) 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=7JLyHZJtRdTTbCdr1AWpBIMP6N5KB46ClouAigDfKUM=; b=Zi0+mLPZRtmx6Nr/4ObCeXRnwl y1bv6dKyo7ObW5HiWKUIfQpK2UtTP5vww1zNY9ah095pZZKchDqdjtYIM4HBu8NJL9qfTzORE+xDm VKevGhyLJSwikXmpSornfpNjZ0RBKgxefODTrOK9TrnzV3vw9OeBeGojrCUIgTH+/xzfZ8n+2tlLX t14IVJfgnR/9U9EQET1LknHKYts+BdgJGUfSDd6dNprynsEmcuGppBhYiyyd4xn1RPiZTe2RR7fGa Z9RZanDBctLqnyBsXpqNarcEUYqXhsjf42lmDYBa2xWtl50U3/Fxoa74ZFSh+s6iXi5/tO87RDb34 T3Y2YGcA==; 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 1kkBCn-0003j8-V0; Tue, 01 Dec 2020 19:20:54 +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 4ED29305C22; Tue, 1 Dec 2020 20:20:50 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 39A4C2BF19AAE; Tue, 1 Dec 2020 20:20:50 +0100 (CET) Date: Tue, 1 Dec 2020 20:20:50 +0100 From: Peter Zijlstra To: Joel Fernandes Cc: Nishanth Aravamudan , Julien Desfossez , Tim Chen , Vineeth Pillai , Aaron Lu , Aubrey Li , tglx@linutronix.de, linux-kernel@vger.kernel.org, mingo@kernel.org, torvalds@linux-foundation.org, fweisbec@gmail.com, keescook@chromium.org, kerrnel@google.com, Phil Auld , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini , vineeth@bitbyteword.org, Chen Yu , Christian Brauner , Agata Gruza , Antonio Gomez Iglesias , graf@amazon.com, konrad.wilk@oracle.com, dfaggioli@suse.com, pjt@google.com, rostedt@goodmis.org, derkling@google.com, benbjiang@tencent.com, Alexandre Chartre , James.Bottomley@hansenpartnership.com, OWeisse@umich.edu, Dhaval Giani , Junaid Shahid , jsbarnes@google.com, chris.hyser@oracle.com, Ben Segall , Josh Don , Hao Luo , Tom Lendacky , Aubrey Li , "Paul E. McKenney" , Tim Chen Subject: Re: [PATCH -tip 22/32] sched: Split the cookie and setup per-task cookie on fork Message-ID: <20201201192050.GX3040@hirez.programming.kicks-ass.net> References: <20201117232003.3580179-1-joel@joelfernandes.org> <20201117232003.3580179-23-joel@joelfernandes.org> <20201125111541.GU2414@hirez.programming.kicks-ass.net> <20201201191133.GA221478@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201201191133.GA221478@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 01, 2020 at 02:11:33PM -0500, Joel Fernandes wrote: > On Wed, Nov 25, 2020 at 12:15:41PM +0100, Peter Zijlstra wrote: > > On Tue, Nov 17, 2020 at 06:19:52PM -0500, Joel Fernandes (Google) wrote: > > > > > +/* > > > + * Ensure that the task has been requeued. The stopper ensures that the task cannot > > > + * be migrated to a different CPU while its core scheduler queue state is being updated. > > > + * It also makes sure to requeue a task if it was running actively on another CPU. > > > + */ > > > +static int sched_core_task_join_stopper(void *data) > > > +{ > > > + struct sched_core_task_write_tag *tag = (struct sched_core_task_write_tag *)data; > > > + int i; > > > + > > > + for (i = 0; i < 2; i++) > > > + sched_core_tag_requeue(tag->tasks[i], tag->cookies[i], false /* !group */); > > > + > > > + return 0; > > > +} > > > + > > > +static int sched_core_share_tasks(struct task_struct *t1, struct task_struct *t2) > > > +{ > > > > > + stop_machine(sched_core_task_join_stopper, (void *)&wr, NULL); > > > > > +} > > > > This is *REALLY* terrible... > > I pulled this bit from your original patch. Are you concerned about the > stop_machine? Sharing a core is a slow path for our usecases (and as far as I > know, for everyone else's). We can probably do something different if that > requirement changes. > Yeah.. so I can (and was planning on) remove stop_machine() from sched_core_{dis,en}able() before merging it. (there's two options, one uses stop_cpus() with the SMT mask, the other RCU) This though is exposing stop_machine() to joe user. Everybody is allowed to prctl() it's own task and set a cookie on himself. This means you just made giant unpriv DoS vector. stop_machine is bad, really bad.