From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B7A1C6FA83 for ; Mon, 5 Sep 2022 16:44:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235938AbiIEQoP (ORCPT ); Mon, 5 Sep 2022 12:44:15 -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-Google-Smtp-Source: AA6agR5IxX+rZOV0sxAdwQEggf0zCPW4siPm15jli7Tzs7+LElEdo/Qe1BbBn5i3TVU8J39X2eN/yg== 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 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