Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36622018rwd; Tue, 11 Jul 2023 03:35:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlE8i6dNzhJ4eXZ5R844jlWa7JHW1zBrrPnXKArHLZoBKEmy4nasPo05jVIMpT0Ei/UWWHxn X-Received: by 2002:a2e:95c2:0:b0:2b6:dbf6:6b38 with SMTP id y2-20020a2e95c2000000b002b6dbf66b38mr8868122ljh.52.1689071732933; Tue, 11 Jul 2023 03:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689071732; cv=none; d=google.com; s=arc-20160816; b=S/LCl4kUaImtGJkCKahnM/NTrhKAx3kOiwJgLj52ZMWJe6Nx5g7TObtk0t0XWFLrvW lB6Ks7/Yr9voCLkzGftVnB7TamEA9NC8TD9WQlDzZVfK8qZtzNpLJcCng0DTcg/l9o85 Ivfk7WHPgZ/QJ12Cn/wnQQlspOpzgt4LO02JXBbeyrqXIy2GVJ/Pnz+MSnEWdE3vHSLl abwlcRESqwkQHp645tszryF7bjAH2EZpfzDk+JdUZpD/K8d4LR5nPYL6b9XvyBSsDirV buku254Ioere8aooqBEGCy37yt4RVh9KIIpiMtDrZxXZIBblE49cUuFjknZQtd57D5zz tJtw== 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=vtPd+yN1U4IqTK91Y6Crv4zudJrwwIEUOH8XFLUTBIk=; fh=oxPhYVaH3K6dRoBQR5dvft4TeBFawrKdpu+R4/k58+U=; b=sBsJM7MZ2W/xTbSjNA1mByJBWsk+fKpFyIC0qhrRHbyx1nbaVf77Rac6EbQGWp3QO3 NF8Ax6kkEZmUs2geBMwIjdV7/0DZeLmkg257XpbtuPXrMXIDlDTJsyHXB8jjF1WSvYx9 FHHzMp80M57SFNBjzWrqgJWa/Q0Uj2Y3f5CPXcEW3F6WGHb/SETScOGJg/cIj6IDB1N9 lbonrolis49XKkmxzH31j8JudVP1I3mpDTF9wJcyI284IhysHi0GwolzhZ8O2/Ao2dHa MH2WlZREl9GW5iN1bzqQFkiUYQ2+DvLTVgLA+QqRJeELVYSi1niUOo+LFnEFIInxs5Nl gEuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=hvSnWQcO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a1709064e1000b00988d4bc0913si1772877eju.478.2023.07.11.03.35.09; Tue, 11 Jul 2023 03:35:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=hvSnWQcO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230426AbjGKKTH (ORCPT + 99 others); Tue, 11 Jul 2023 06:19:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbjGKKS7 (ORCPT ); Tue, 11 Jul 2023 06:18:59 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 835DCDB for ; Tue, 11 Jul 2023 03:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=vtPd+yN1U4IqTK91Y6Crv4zudJrwwIEUOH8XFLUTBIk=; b=hvSnWQcO6AvhXvooZhbMvXWvsD nvp9B+MHb11v440DDTeYLHOU6tgz3037srEf9cWGxMnaFWPe9iyvnR31Effg9zOFfvg67JpHoTNP7 uLPgMxOwvbZYz7I4lEU4XTz+luagGQ12v5RAfAyCwtV63IwOgoGikK9mXfc6iPPmrTO9M7XnxLjeF yX+7V7VnIxskknxlXCXy1khl0hD8VLsPyAzEYaV2aExTAIaj/cabdW/dYVcEw1w76bpTGLde5t4JS tBYRP5PG94qiRTdOfuKEu8BitWE8Y/1ubwZvBm7t1CZh7gmxqd6qeiXQmWbt9WGXpv6mr+0UncX2H 1nL7eIhg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qJAS1-00FcUY-SJ; Tue, 11 Jul 2023 10:18:34 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 71A1E3002B1; Tue, 11 Jul 2023 12:18:32 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 587DB243429D0; Tue, 11 Jul 2023 12:18:32 +0200 (CEST) Date: Tue, 11 Jul 2023 12:18:32 +0200 From: Peter Zijlstra To: David Vernet Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, gautham.shenoy@amd.com, kprateek.nayak@amd.com, aaron.lu@intel.com, clm@meta.com, tj@kernel.org, roman.gushchin@linux.dev, kernel-team@meta.com Subject: Re: [PATCH v2 5/7] sched: Implement shared runqueue in CFS Message-ID: <20230711101832.GF3062772@hirez.programming.kicks-ass.net> References: <20230710200342.358255-1-void@manifault.com> <20230710200342.358255-6-void@manifault.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230710200342.358255-6-void@manifault.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 10, 2023 at 03:03:40PM -0500, David Vernet wrote: > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 1451f5aa82ac..3ad437d4ea3d 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -9842,6 +9843,7 @@ void __init sched_init_smp(void) > > init_sched_rt_class(); > init_sched_dl_class(); > + init_sched_fair_class_late(); > > sched_smp_initialized = true; > } > @@ -12854,3 +12999,34 @@ __init void init_sched_fair_class(void) > #endif /* SMP */ > > } > + > +__init void init_sched_fair_class_late(void) > +{ > +#ifdef CONFIG_SMP > + int i; > + struct shared_runq *shared_runq; > + struct rq *rq; > + struct rq *llc_rq; > + > + for_each_possible_cpu(i) { > + if (per_cpu(sd_llc_id, i) == i) { > + llc_rq = cpu_rq(i); > + > + shared_runq = kzalloc_node(sizeof(struct shared_runq), > + GFP_KERNEL, cpu_to_node(i)); > + INIT_LIST_HEAD(&shared_runq->list); > + spin_lock_init(&shared_runq->lock); > + llc_rq->cfs.shared_runq = shared_runq; > + } > + } > + > + for_each_possible_cpu(i) { > + rq = cpu_rq(i); > + llc_rq = cpu_rq(per_cpu(sd_llc_id, i)); > + > + if (rq == llc_rq) > + continue; > + rq->cfs.shared_runq = llc_rq->cfs.shared_runq; > + } > +#endif /* SMP */ > +} I don't think this is right; the llc_id thing depends on the online mask, not on possible mask. So if you boot with a number of CPUs offline and late bring them online, you're screwy (IIRC this is actually a very common thing in virt land). Additionally, llc_id depends on the sched_domain tree, if someone were to go create partitions, they can split an LLC and llc_id would split right along with it. I think you need to move this into sched/topology.c and handle hotplug / domain (re) creation. And yes, that's going to be a pain, because you might need to re-hash existing lists.