Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3355532rwb; Mon, 5 Sep 2022 10:09:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR6hwSzSQf8tWvynAGT61x2yjT83QOjSOmR0/J/cq9fuM562pcwAdRNp7pGg6ZNumKOXpqpQ X-Received: by 2002:a17:906:730d:b0:73d:c8a1:a6ae with SMTP id di13-20020a170906730d00b0073dc8a1a6aemr37499843ejc.540.1662397780970; Mon, 05 Sep 2022 10:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662397780; cv=none; d=google.com; s=arc-20160816; b=cHtkkocGT7WPv0TSWIyaGN5nnkddp5pf4GDqm1Vqd2cVAdbjAJZ5f216GCnW6Ez1eO myak27hNdhd/mcwmXSCmcOcwKLT42/OtbD3niFanzGw4NnHUiKCjx2B125OMHmWqLyfA RuF8VhNR130xHA8rY3zAhRvbeXZyqhrNk0cnlhgWxE2I5U3q/g7jWueQ21oF5iw+sLLd 96Nm1j3Xh6SnU8stDVS9rUKQC0eNLgWHNH6Vou5Qy+6ALomnEzXF9L8+FuXuKf6YYbHL cbzUpJ3LjKy/vyCXgJDyer5AwI2UaH2dYMZbfSyPfVFSGY0DQjvbeMYAxyBavQvfMK+F R+ww== 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=rFN8kU4pPUwKGAD0Wxcp7MwYS+FD1wiqpVVQEqbcbG4=; b=wmd19vS2i90ASp/Q0y28vHpULSJkBPBzkPi+9i5QtXRPE3x5qZ4PIW+Bg4Gm04M++F T6KUtzUEgPYAn2YJ/QKhQB/GeEAAwa+YOwbOmC+NFiKtJ1VgSaetz/EFmGDcXZAFYcht S/9XNmFKObnD9nnufjKogd/vu4ByaWwJiOWC1+hXrLNw/e5dNzJwXKlVxR8TDEKoFEdS dL5pP0IyHW69RmwQ7MA0Az3ED/nGcO856UPGQX4gj7oh7eJriOAs7RFwAfO6Lt/lGmYo JPLtBlMD/dJhTWGW+Rj5bZ/Y2MHIDecFGF8Dn9m199SrFMiX9ubf/U0d6zMaize54JQW Cu9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fF3DXUzY; 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 fd5-20020a056402388500b0044dc1faa85dsi3937766edb.253.2022.09.05.10.09.06; Mon, 05 Sep 2022 10:09:40 -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=fF3DXUzY; 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 S231929AbiIEQoO (ORCPT + 99 others); Mon, 5 Sep 2022 12:44:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231296AbiIEQoL (ORCPT ); Mon, 5 Sep 2022 12:44:11 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B10261B16 for ; Mon, 5 Sep 2022 09:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662396249; 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=rFN8kU4pPUwKGAD0Wxcp7MwYS+FD1wiqpVVQEqbcbG4=; b=fF3DXUzYx4eFEBYdRplycS7CGVFDFoI93+ghfm67c00j2TkWi+7cSKmXh5ylphwCM8DeUQ xzN9Sm98MUMO/LVLzzkSEBUf4hHIukCQTuAp6Xft74qhBZ8svX5dG2wQjTnktcbWRN5PLE PZM8DDM7Is13VzkHZnL/B0GlGY0ebkw= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-79-MNutk--AN0m72-mMI_dM2A-1; Mon, 05 Sep 2022 12:44:08 -0400 X-MC-Unique: MNutk--AN0m72-mMI_dM2A-1 Received: by mail-wr1-f69.google.com with SMTP id d30-20020adfa41e000000b00228c0e80c49so626620wra.21 for ; Mon, 05 Sep 2022 09:44:08 -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:subject:date; bh=rFN8kU4pPUwKGAD0Wxcp7MwYS+FD1wiqpVVQEqbcbG4=; b=chBFt9azJN2rvfa6WHb+6PR6a02q+rfRza4uh0eLyD6PXBDSyAV2h4yD+AfK9oFkR5 DruVZnOqgR9eiIPA/NhQOmqDieYte3GugNkqN1lNlAT/pnjYDnM23rtNwP2K6LEYbX5P Dv6Gyoj2cNaq3lX6MldlumxgXOHno4gmTdoxdMeks8i8qDAh4QtFXm1KQk4WIVUmrwiO K7C90tIbfXlP0jswss2QxmGt4mX4DKE8JqjGaeklQ4IRX9hokF/FGb8ueNLj0T3IPHDK Ic58sdtXtc/x2Vrgzp6I6zMxqoHIJ73l95AvaarkTUtsBRxERTjhQtat2IHeXyC6NT+L HVlg== X-Gm-Message-State: ACgBeo3rWq007hpXtaHcSSDICY6Hj46O99KeZhvtLelMQ3NUtx6Gw9x+ R6iVW629p5rrzUfQ1BfSnZesFJmLjaWrnX+S5Ev1c6U9+RLEwsPeiYl/jsEzqHjA+oPNHT01BE2 iFaKP7eV1n7cKoZ3RsgkKi0FX X-Received: by 2002:adf:f54a:0:b0:228:951a:2949 with SMTP id j10-20020adff54a000000b00228951a2949mr2874152wrp.240.1662396246969; Mon, 05 Sep 2022 09:44:06 -0700 (PDT) X-Received: by 2002:adf:f54a:0:b0:228:951a:2949 with SMTP id j10-20020adff54a000000b00228951a2949mr2874125wrp.240.1662396246798; Mon, 05 Sep 2022 09:44:06 -0700 (PDT) Received: from vschneid.remote.csb ([185.11.37.247]) by smtp.gmail.com with ESMTPSA id k27-20020a05600c1c9b00b003a845fa1edfsm29552176wms.3.2022.09.05.09.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 09:44:06 -0700 (PDT) From: Valentin Schneider To: Yury Norov Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andy Shevchenko , Rasmus Villemoes , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Mel Gorman , Greg Kroah-Hartman , Heiko Carstens , Tony Luck , Jonathan Cameron , Gal Pressman , Tariq Toukan , Jesse Brandeburg Subject: Re: [PATCH v3 4/9] cpumask: Introduce for_each_cpu_andnot() In-Reply-To: References: <20220825181210.284283-1-vschneid@redhat.com> <20220825181210.284283-5-vschneid@redhat.com> Date: Mon, 05 Sep 2022 17:44:05 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 25/08/22 14:14, Yury Norov wrote: > On Thu, Aug 25, 2022 at 07:12:05PM +0100, Valentin Schneider wrote: >> +#define for_each_cpu_andnot(cpu, mask1, mask2) \ >> + for ((cpu) = -1; \ >> + (cpu) = cpumask_next_andnot((cpu), (mask1), (mask2)), \ >> + (cpu) < nr_cpu_ids;) > > The standard doesn't guarantee the order of execution of last 2 lines, > so you might end up with unreliable code. Can you do it in a more > conventional style: > #define for_each_cpu_andnot(cpu, mask1, mask2) \ > for ((cpu) = cpumask_next_andnot(-1, (mask1), (mask2)); \ > (cpu) < nr_cpu_ids; \ > (cpu) = cpumask_next_andnot((cpu), (mask1), (mask2))) > IIUC the order of execution *is* guaranteed as this is a comma operator, not argument passing: 6.5.17 Comma operator The left operand of a comma operator is evaluated as a void expression; there is a sequence point after its evaluation. Then the right operand is evaluated; the result has its type and value. for_each_cpu{_and}() uses the same pattern (which I simply copied here). Still, I'd be up for making this a bit more readable. I did a bit of digging to figure out how we ended up with that pattern, and found 7baac8b91f98 ("cpumask: make for_each_cpu_mask a bit smaller") so this appears to have been done to save up on generated instructions. *if* it is actually OK standard-wise, I'd vote to leave it as-is. >> + >> /** >> * cpumask_any_but - return a "random" in a cpumask, but not this one. >> * @mask: the cpumask to search >> -- >> 2.31.1