Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5769408rwb; Tue, 9 Aug 2022 03:57:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Xpa4S0AIrds9Ab47zhRCZ0oDJZxB2YKBp7TEJw8GzYOp3YQyDNF3SzuqaMWHIfWRrb63O X-Received: by 2002:a17:907:2c47:b0:730:6dfb:b32c with SMTP id hf7-20020a1709072c4700b007306dfbb32cmr16811351ejc.284.1660042647342; Tue, 09 Aug 2022 03:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660042647; cv=none; d=google.com; s=arc-20160816; b=Rl6u7zRrYDvC4A7i2BoamWec3clFfVi1qVNiZq91abgHNFRshBzBKHH2fK9Z+64Prw MdtUhjBB5RO5S3AlODRbGsBYZg6/nES3s81QuegRM/2CcKNITH8OOPwOkEyWv6xMdm3y lSy7rwZML09wBFDVAEHZctl/2vrnJ/x+g3FJg7lyYoMxpMAvqBjllpS1Rs87ig7sMsDT ExNXjnmakh3TeZJgL/bRik1x9o0IlCG+bSlnlqLnUCI1IohLs9gthZZ8Za/Z6hpWN8rg TT1NH5FDZey8glFVGYPoQaEmN5Bc1y9iHgPBnlhW/3F/upXETDF8gA0qFiMVagB14XHh R32Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=JQ4rx3p2EcFXQ1V5iVeBvBViEa90MF16sMNOOJrJ4ZY=; b=bpS5on6ZnXt1DhWWWKIfuFAhytaF/+CqFsTeJKBTjUCLyraTq/DBaPIdwlPIQHOo2M Iy6isuK/ALcSBFUZAVzFnwOHw86bDJ7W/Fw9bYW97LXHysOs+q1thEVLEMbEa/qX7BJX +Zkjk5sloQKQJeSwQduC+Jn7jP4SvUPtsa4zyo86Iy29B/F5dFPhyDYzFJEn7/bGsACj OAj2Qqa+PLRDqhYL70EY6naSDgM/LyLMcS3eJ5IDddArgWlyds5sR6JLtq8CvaNwxYO0 Jbs7tAmM8jd2YcjgaorplbEWI2GkyeKRJXNsd8LLorUUIhlu2fZs4EGCp/lzBj28l+Pl VA4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TDVLhPFU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go16-20020a1709070d9000b0072b4cba9671si1974171ejc.186.2022.08.09.03.57.01; Tue, 09 Aug 2022 03:57:27 -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=@redhat.com header.s=mimecast20190719 header.b=TDVLhPFU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240389AbiHIKCQ (ORCPT + 99 others); Tue, 9 Aug 2022 06:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240117AbiHIKCO (ORCPT ); Tue, 9 Aug 2022 06:02:14 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 838CE21E1E for ; Tue, 9 Aug 2022 03:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660039332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JQ4rx3p2EcFXQ1V5iVeBvBViEa90MF16sMNOOJrJ4ZY=; b=TDVLhPFUWTPmUAtj4rx8UuRmd7wsibOtfNqIFDa2dFb90rmduo8AwjIBGfwzfqvRVRsyRD FnNxzyAeff9F0H8b0U/Z5h8dBJ66euSe/OxKzIrX9RYCH3+udH/pXVBYew39j7k+P1XMiH AIGM7oRNUiiuMm5MSpElsWtDyUk2GaQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-316-L4opxke5M7GWzXJapHC_cw-1; Tue, 09 Aug 2022 06:02:11 -0400 X-MC-Unique: L4opxke5M7GWzXJapHC_cw-1 Received: by mail-wm1-f69.google.com with SMTP id b16-20020a05600c4e1000b003a5a47762c3so102009wmq.9 for ; Tue, 09 Aug 2022 03:02:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc; bh=JQ4rx3p2EcFXQ1V5iVeBvBViEa90MF16sMNOOJrJ4ZY=; b=Hutdb0CKmQgErR53uXPoh7gIpiQbBWy1HxuUp8YqnTyFLm5bGVsFLyE00etPlfOfjA JIu63fTC4yhACH+arxW6ii9/pW4IdLH021keWGqHtqHnA3bx0/6Ze3icilhNfXZjTo3J CXlOM/bxXbTe9kjbX8t3SA1iCs5kW59N2VOc/6JF29KEVyxSbKN1+Pb/EoL5RLitQ1yC zZmZaYV43zCJAm7yfCS28fV/R6lXnR0SloS24J5qklLkgf2WaYZEdyzxKnQmL18T4Jzt 3IzN7QoXsVGap5Or/gSUWREiaqRqx0incMG3ARfnuk/Q4UbzoY/x+oxgGCzx6AadV9T0 ZQDQ== X-Gm-Message-State: ACgBeo2lPMSzY8O/VX8MlScYe6zGOKPVqvcf/0GOqQWAyg1N3LFFLaJY T6cvPtsadoXMzA5Ys0+1GENd1mQfGkMN/gbpLVA9LpTEq17KAZtI5+ePbnRZc47lIzIEFruNQzN ftNBtz7dLE/QRMH75uI6CQf9ewlpx0yJJmfG1GJnDYCaKRHDvqU0NecRbvRoGpnd8Q+dW3tSKGn P0 X-Received: by 2002:a05:600c:4e41:b0:3a5:1a0c:c52 with SMTP id e1-20020a05600c4e4100b003a51a0c0c52mr12748590wmq.51.1660039329914; Tue, 09 Aug 2022 03:02:09 -0700 (PDT) X-Received: by 2002:a05:600c:4e41:b0:3a5:1a0c:c52 with SMTP id e1-20020a05600c4e4100b003a51a0c0c52mr12748545wmq.51.1660039329572; Tue, 09 Aug 2022 03:02:09 -0700 (PDT) Received: from vschneid.remote.csb ([185.11.37.247]) by smtp.gmail.com with ESMTPSA id p19-20020a05600c359300b003a32297598csm21171607wmq.43.2022.08.09.03.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 03:02:08 -0700 (PDT) From: Valentin Schneider To: Tariq Toukan , Tariq Toukan , "David S. Miller" , Saeed Mahameed , Jakub Kicinski , Ingo Molnar , Peter Zijlstra , Juri Lelli Cc: Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, Gal Pressman , Vincent Guittot , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next V4 1/3] sched/topology: Add NUMA-based CPUs spread API In-Reply-To: References: <20220728191203.4055-1-tariqt@nvidia.com> <20220728191203.4055-2-tariqt@nvidia.com> Date: Tue, 09 Aug 2022 11:02:07 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 08/08/22 17:39, Tariq Toukan wrote: > On 8/4/2022 8:28 PM, Valentin Schneider wrote: >> On 28/07/22 22:12, Tariq Toukan wrote: >>> +static bool sched_cpus_spread_by_distance(int node, u16 *cpus, int ncpus) >> ^^^^^^^^^ >> That should be a struct *cpumask. > > With cpumask, we'll lose the order. > Right, I didn't get that from the changelog. >> >>> +{ >>> + cpumask_var_t cpumask; >>> + int first, i; >>> + >>> + if (!zalloc_cpumask_var(&cpumask, GFP_KERNEL)) >>> + return false; >>> + >>> + cpumask_copy(cpumask, cpu_online_mask); >>> + >>> + first = cpumask_first(cpumask_of_node(node)); >>> + >>> + for (i = 0; i < ncpus; i++) { >>> + int cpu; >>> + >>> + cpu = sched_numa_find_closest(cpumask, first); >>> + if (cpu >= nr_cpu_ids) { >>> + free_cpumask_var(cpumask); >>> + return false; >>> + } >>> + cpus[i] = cpu; >>> + __cpumask_clear_cpu(cpu, cpumask); >>> + } >>> + >>> + free_cpumask_var(cpumask); >>> + return true; >>> +} >> >> This will fail if ncpus > nr_cpu_ids, which shouldn't be a problem. It >> would make more sense to set *up to* ncpus, the calling code can then >> decide if getting fewer than requested is OK or not. >> >> I also don't get the fallback to cpumask_local_spread(), is that if the >> NUMA topology hasn't been initialized yet? It feels like most users of this >> would invoke it late enough (i.e. anything after early initcalls) to have >> the backing data available. > > I don't expect this to fail, as we invoke it late enough. Fallback is > there just in case, to preserve the old behavior instead of getting > totally broken. > Then there shouldn't be a fallback method - the main method is expected to work. >> >> Finally, I think iterating only once per NUMA level would make more sense. > > Agree, although it's just a setup stage. > I'll check if it can work for me, based on the reference code below. > >> >> I've scribbled something together from those thoughts, see below. This has >> just the mlx5 bits touched to show what I mean, but that's just compile >> tested. > > My function returns a *sorted* list of the N closest cpus. > That is important. In many cases, drivers do not need all N irqs, but > only a portion of it, so it wants to use the closest subset of cpus. > Are there cases where we can't figure this out in advance? From what I grok out of the two callsites you patched, all vectors will be used unless some error happens, so compressing the CPUs in a single cpumask seemed sufficient.