Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3504458pxb; Mon, 24 Jan 2022 10:57:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJx47+sVV1np7XeVPJjYjdncAQtDFXP45g9vidTFcC96lNa8lD+mJ0DF6FWDkaLctl6DkzBX X-Received: by 2002:a63:8042:: with SMTP id j63mr10608099pgd.267.1643050651515; Mon, 24 Jan 2022 10:57:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643050651; cv=none; d=google.com; s=arc-20160816; b=NVo0ugK2O2x1xjdzfie3AMZRlGqtKp+LWihz4IidCUa5AcPK2CeXlxCMrBgfiBvWcc mncACMII8GzVQWTveqGtKA6RzacgPgBn8rbhXLwA+qvVfxzo3eY6H4F9KE0O4MTYJeEs EUx5t7OxD43CKbD7KJLUUeogIe7Er4JhYuEKf6sUZMdVC41tb33Fn1A4b5tfvB3n6v+8 D6j18m2L38pmK+316a8gLyZjUaCJ13cMfsbQrM77HVhMH/OyfNRDo1h1MkErVRdwXjQW zDFNzw63tQuzf991c+lCGyfP0rsexnGufY91wB/2XLJU0erbEiyHl/eDq125EUjwBj9N TeRA== 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=JrLz3L3tcI/I3BMhVWiGKT3p97BtzBHRcz9TbUScQEA=; b=wPgs22Fah3eKa4/KSPiS+j0dYGwTdE1SXq0UtSI268LSJ0uGv10NPqDvfTiJAFIynI XdYNZ2pJS4M9VVOuAkAP7LpvIpWfUp1Uel7Akb+lkOYnEY5KQ65e7G8MChEUGYhDyVJx Hw5B12f+OxmISBXmnApPKS12w4LcS1C47Y8oqwkaifXbH4RwB0kVkzZdz16vypANvnxr Z1i/YflmLkFFodsBVt1uNKYPIOZpOAIFw8eoMGMU+hu6w72RSPKCULiREdMHD3Jg/fBI 62undhE8O7Hx/pTZwSQNxEgw5WZ6FL21eHuKWCb5MaDeRpw7Md21LFBG9puO315rhRaN FbIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iY2NuSFV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gf11si126530pjb.71.2022.01.24.10.57.16; Mon, 24 Jan 2022 10:57:31 -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=@redhat.com header.s=mimecast20190719 header.b=iY2NuSFV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232577AbiAXJUo (ORCPT + 99 others); Mon, 24 Jan 2022 04:20:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57154 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231851AbiAXJUg (ORCPT ); Mon, 24 Jan 2022 04:20:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643016033; 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=JrLz3L3tcI/I3BMhVWiGKT3p97BtzBHRcz9TbUScQEA=; b=iY2NuSFV1q4+9h3OWqL3ukwaXKHzrK2aHNZFxbJhqL/8ugWrvLYKXNWsOtrxHpCUvP34cN 7org6r5rQZa0qeG1iZ6YXiVf8dP3W3OH4lYIaxdc8BQGqRMbKqRpXblK7t3EdT0/R+TRmd StPnDEIxauMrshr7EVvld3zSjufO3GE= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-sVK2baS2PrO6OtYlEX78Lw-1; Mon, 24 Jan 2022 04:20:32 -0500 X-MC-Unique: sVK2baS2PrO6OtYlEX78Lw-1 Received: by mail-wm1-f72.google.com with SMTP id v185-20020a1cacc2000000b0034906580813so14675222wme.1 for ; Mon, 24 Jan 2022 01:20:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=JrLz3L3tcI/I3BMhVWiGKT3p97BtzBHRcz9TbUScQEA=; b=SYQRDWiRHxlTC9xzwDkaPuDMMDdXAS5E05QU22X6eMGYUMolInh0tt2NalQl3pz8om I6+eF86QpZ9aKwJ36vU2DqFyvjSlJfPpLKpegDNfbMsEAQuRSFvjDQF2W6JxSYWHVFja oc6+UVpSncqHlA32hvzd4w9OTLNPAh/50sQKcXqHJr/NaF2c8CTM5o9mV3FEW/yesgRh wjHG8UxoZ90GRXBDwAGJiOLv/Vsu80PMbcRLM94KqDvfJn1FOpPTXPSHFcRrNVe4DDtF D/s/czsneVuqlndIJTLd89uWxXcKtIYz+s+cq2aDIRZFB5AzYgPgT/GBpGF391OgTfQl yxjQ== X-Gm-Message-State: AOAM533LnjSWFabxHr3xHtY67Wr6hgI1BIxucUQvoHu2PYdyOCvLAH3H 1eHx/DBCSYTNmeRhVpGw1fh/FNYn+pIYHywkrEMM8/YZagwI/iM+hgcGjPw0K6Qw30F+XAkxmKl X+3dM10+sWSo2wHqCW3OEAGc1 X-Received: by 2002:a05:6000:15cd:: with SMTP id y13mr8194683wry.717.1643016016240; Mon, 24 Jan 2022 01:20:16 -0800 (PST) X-Received: by 2002:a05:6000:15cd:: with SMTP id y13mr8194655wry.717.1643016016053; Mon, 24 Jan 2022 01:20:16 -0800 (PST) Received: from fedora (nat-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id 31sm16657869wrl.27.2022.01.24.01.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 01:20:15 -0800 (PST) From: Vitaly Kuznetsov To: Yury Norov Cc: Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?Q?Micha=C5=82_Miros=C5=82aw?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , linux-hyperv@vger.kernel.org Subject: Re: [PATCH 43/54] drivers/hv: replace cpumask_weight with cpumask_weight_eq In-Reply-To: <20220123183925.1052919-44-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> <20220123183925.1052919-44-yury.norov@gmail.com> Date: Mon, 24 Jan 2022 10:20:13 +0100 Message-ID: <87sftdij76.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Yury Norov writes: > init_vp_index() calls cpumask_weight() to compare the weights of cpumasks > We can do it more efficiently with cpumask_weight_eq because conditional > cpumask_weight may stop traversing the cpumask earlier (at least one), as > soon as condition is met. Same comment as for "PATCH 41/54": cpumask_weight_eq() can only stop earlier if the condition is not met, to prove the equality all bits need always have to be examined. > > Signed-off-by: Yury Norov > --- > drivers/hv/channel_mgmt.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c > index 60375879612f..7420a5fd47b5 100644 > --- a/drivers/hv/channel_mgmt.c > +++ b/drivers/hv/channel_mgmt.c > @@ -762,8 +762,8 @@ static void init_vp_index(struct vmbus_channel *channel) > } > alloced_mask = &hv_context.hv_numa_map[numa_node]; > > - if (cpumask_weight(alloced_mask) == > - cpumask_weight(cpumask_of_node(numa_node))) { > + if (cpumask_weight_eq(alloced_mask, > + cpumask_weight(cpumask_of_node(numa_node)))) { This code is not performace critical and I prefer the old version: cpumask_weight() == cpumask_weight() looks better than cpumask_weight_eq(..., cpumask_weight()) (let alone the inner cpumask_of_node()) to me. > /* > * We have cycled through all the CPUs in the node; > * reset the alloced map. -- Vitaly