Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36649294rwd; Tue, 11 Jul 2023 04:02:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlFqUALterdJxMXHNPxtQ9faEgJkTKLwSqN/2I3GDyNTahroXlnpCHSF9ECrMN4X/STCPkUw X-Received: by 2002:ac2:58f6:0:b0:4f8:4255:16ca with SMTP id v22-20020ac258f6000000b004f8425516camr11613418lfo.38.1689073344978; Tue, 11 Jul 2023 04:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689073344; cv=none; d=google.com; s=arc-20160816; b=pGUcfJwkwz6VVOMkDioW/LxA7/sqjKm/3scW09z/xDWkPohRO7RzJdzcxlqJPAHgzH w85La4akYghRIBmxgaFjaAz8pInXG1n556FGXW8A8i1zkwEczvT3cwven+nGcPW67OX4 GQycumFRauMGyBIPey5RD9SDNm6b7rbUz45lHNdmbBTEoPK4J98yR70QZdpx3wSPs4B9 QzKUB4JCCuMxLOD2QIF3XMca+/Xv1EosBmp5k1PwesndsmOwDGZD5mD+uZYq06dDrcfB 0SD64N0nLdPsUmCUSw1LGS5Bfj0xbkjH0J7tHLeQ4TmBX1NuTngq8gR3LWjM2b7M4TD6 hM6A== 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=ecCqrheGFPVMgRUOdp7TQlIig7O7kKKA9pd8sM96z/Y=; fh=oxPhYVaH3K6dRoBQR5dvft4TeBFawrKdpu+R4/k58+U=; b=rYaUhklrLm8Revkwfh8EheNkS+6ezT7BIpWV7g0uVtVi15PH2qs5EguG73nLEO73wM vtf6xSnAJ7oD9Va91p+SLwUWc85DWPhw2s02tyCfbGDk4sH6G0MdzCmwW4FPZb3NimEc AmsX5rXF9ZhlJWwBpetVJGUaw3eSg1wX6LudAstcsfzNpouJ1Dckc0K+xdh5iDN2KdLt ZPH3EuF96J080+uMlG+dwE+XM5XgX2qZD4Tnzmnj6EeucHNyQspYkKU23s5kbEo5uEqC QZ/PcwHz1L5KrkZZaug8MG25qFtMNwgLZLSQ3bH8v9/tyeJCwAwi9Qo48rPjN/9ik4Gk OJmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Rf3KwuXM; 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 by11-20020a0564021b0b00b0051df7f18d3esi1705314edb.673.2023.07.11.04.02.00; Tue, 11 Jul 2023 04:02:24 -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=desiato.20200630 header.b=Rf3KwuXM; 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 S230375AbjGKKue (ORCPT + 99 others); Tue, 11 Jul 2023 06:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbjGKKud (ORCPT ); Tue, 11 Jul 2023 06:50:33 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA56EE74 for ; Tue, 11 Jul 2023 03:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=ecCqrheGFPVMgRUOdp7TQlIig7O7kKKA9pd8sM96z/Y=; b=Rf3KwuXMbgkJzpPw9km4D9JP+n zaJ41Gw8OMgHlAq79Tqm1Kb+33M0rCt/koRJvDD6u6QacHrWzrsqmSCwSZDGYThs9EpSqYnGFIVm7 ZoQKdqTK/q4womBZXDUJ23QK1Hb6bRs37icmmO7mjFRoc4+ZsXDcJm7K3rOJJhzDY+AFg5ASiXAsX qM8wkUBOy+lxALSxqKqQaOlo0Gr46eO/ITBil1R7g7G6pSQBEWT9u/Vp1Wo+E0pCVf/Q3IOFFbSkZ 5/y2sNXwmJjd1eQmiXPLxLZ8+zrmGDAqKa23efFMWCVmt8Dw5ry7vuPg6sHjpv0sS+gtywhfn+jWC OVqoT0vQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qJAwU-002NAX-09; Tue, 11 Jul 2023 10:50:02 +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) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 2B1C930036B; Tue, 11 Jul 2023 12:49:59 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 12982243429D0; Tue, 11 Jul 2023 12:49:59 +0200 (CEST) Date: Tue, 11 Jul 2023 12:49:58 +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 6/7] sched: Shard per-LLC shared runqueues Message-ID: <20230711104958.GG3062772@hirez.programming.kicks-ass.net> References: <20230710200342.358255-1-void@manifault.com> <20230710200342.358255-7-void@manifault.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230710200342.358255-7-void@manifault.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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:41PM -0500, David Vernet wrote: > +struct shared_runq_shard { > struct list_head list; > spinlock_t lock; > } ____cacheline_aligned; > > +struct shared_runq { > + u32 num_shards; > + struct shared_runq_shard shards[]; > +} ____cacheline_aligned; > + > +/* This would likely work better as a configurable knob via debugfs */ > +#define SHARED_RUNQ_SHARD_SZ 6 > + > #ifdef CONFIG_SMP > static struct shared_runq *rq_shared_runq(struct rq *rq) > { > return rq->cfs.shared_runq; > } > > -static struct task_struct *shared_runq_pop_task(struct rq *rq) > +static struct shared_runq_shard *rq_shared_runq_shard(struct rq *rq) > +{ > + return rq->cfs.shard; > +} > + > +static int shared_runq_shard_idx(const struct shared_runq *runq, int cpu) > +{ > + return cpu % runq->num_shards; I would suggest either: (cpu >> 1) % num_shards or keeping num_shards even, to give SMT siblings a fighting chance to hit the same bucket. (I've no idea how SMT4 (or worse SMT8) is typically enumerated, so someone from the Power/Sparc/MIPS world would have to go play with that if they so care) > +} > + num_shards = max(per_cpu(sd_llc_size, i) / > + SHARED_RUNQ_SHARD_SZ, 1); > + shared_runq->num_shards = num_shards;