Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2162373iof; Tue, 7 Jun 2022 21:50:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwo7pJFNAu1RCdqFy0iGbrVZm1Y7AWS0c5OrVPW42USyEQbJxnk/Rujqsjsk9ErdFIpB3r0 X-Received: by 2002:a17:90b:4f41:b0:1e4:9081:6aa with SMTP id pj1-20020a17090b4f4100b001e4908106aamr35220509pjb.183.1654663805010; Tue, 07 Jun 2022 21:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654663805; cv=none; d=google.com; s=arc-20160816; b=NT0mzQ5SPuFM5tIVWDGi1UbA45WeI7p2dlRumFzi5GILXq61DGXtTUhMrbn87Oh17t Ovn519l/zxCYjycqsd60FiHASriOhGmEP8MRNUZ17Z/F+O79F0QkrtWVYh9UiwSyAnMi r6onmzLPAqESdTq0IsKaqkqaHS6wzR/IV3J7HCF5JA5uftNi0sODVFSafJaEWAuGeCfd vXyPS8bwlZf5rvSiIX7G5OG6sPkFpRqyr/jYK7hxuY07BTu8ROIeYACRsRRFHVkbWknr G5lq7OilwwMka72nVmZngqRDoN+tnSogaolBSc6W77RmOT6zE/K/rp9j1OXTb+TZF+iP RDDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NZtOcjzA17ueHLcbWh0FLe/R7Y0z9C8DU/fDXzSq8MM=; b=muBljBNsoZEX289IbcjutMf0ruyu7w/wCjwA8IKpW7V4cNIOiGHw5OVbJvBw4sSuon TwyDGChvNj4ja1GUu3rNmwm/SNt+elmsiQNq7bKO7JHQmvcFsjaY8LcBjEdXBDYWYJ2h FOwwpQr3KYS27kEuGZMW1C7E/9ClLvBxlMT6aKYVSegZ3UMvi8wTihKTn7t65Qz6hzjx RvA4hb0le5HrN4aWaVAL2LSICGsBJU0dh2iWOHO5/IYMWrc4/DineysDxn9z2d6jNgjz lPb3Oy5aPr9oMftsRM2q8OwlCcHm44zGdop2iUPd+FZyjpWDEUSP2jUashQMiPUEj8+t GDUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZuD7XJun; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t1-20020a17090340c100b0015eabaaa16fsi23369003pld.578.2022.06.07.21.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:50:04 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZuD7XJun; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A2BEB144BEF; Tue, 7 Jun 2022 21:20:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242493AbiFGLJN (ORCPT + 99 others); Tue, 7 Jun 2022 07:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242620AbiFGLIr (ORCPT ); Tue, 7 Jun 2022 07:08:47 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2245B10F365; Tue, 7 Jun 2022 04:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654599888; x=1686135888; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=txlfXjkncT5hC674qNejQhjc3HzGWH2n9+3fSqXFElg=; b=ZuD7XJunqF+oQFgLH70hHJJzUyDX/9Yyc6z/CGQlpdoTx2vRCSnUIMdU c+zfWhewQS+lC0l415FmCsQO53rJ3rhge8dFjRY8a1jhFcm63Mrp0WMax P6O85A56btM6uWNuhZisYsr0CngEkzk9lZJDaEp1LiHgLMy2IgiuryQsw qREJIxgAk54i4xKov6l73S0FeHzeVIP8Sd//H8/nuzDdMYWgpIEUldZ6B dx/PtK3dqDIHU38EmKFI/JcKuKg+qZy7W6E9DR1nJCP7fXN7Krkcx1Dgu 3BozaNrA6+MRwCS0xy9xiJHRXuyEIg2IordpDtehhM98fpeYUsJiMw9O1 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10370"; a="338066809" X-IronPort-AV: E=Sophos;i="5.91,283,1647327600"; d="scan'208";a="338066809" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2022 04:04:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,283,1647327600"; d="scan'208";a="614870759" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga001.jf.intel.com with ESMTP; 07 Jun 2022 04:04:18 -0700 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 257B4GZI020549; Tue, 7 Jun 2022 12:04:16 +0100 From: Alexander Lobakin To: Yury Norov Cc: Alexander Lobakin , Arnd Bergmann , Andy Shevchenko , Richard Henderson , Matt Turner , Brian Cain , Geert Uytterhoeven , Yoshinori Sato , Rich Felker , "David S. Miller" , Kees Cook , "Peter Zijlstra (Intel)" , Marco Elver , Borislav Petkov , Tony Luck , Greg Kroah-Hartman , linux-alpha@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/6] bitops: unify non-atomic bitops prototypes across architectures Date: Tue, 7 Jun 2022 13:03:10 +0200 Message-Id: <20220607110310.72649-1-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: <20220606114908.962562-1-alexandr.lobakin@intel.com> <20220606114908.962562-5-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_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 From: Yury Norov Date: Mon, 6 Jun 2022 13:48:50 -0700 > On Mon, Jun 06, 2022 at 01:49:05PM +0200, Alexander Lobakin wrote: > > Currently, there is a mess with the prototypes of the non-atomic > > bitops across the different architectures: > > > > ret bool, int, unsigned long > > nr int, long, unsigned int, unsigned long > > addr volatile unsigned long *, volatile void * > > > > Thankfully, it doesn't provoke any bugs, but can sometimes make > > the compiler angry when it's not handy at all. > > Adjust all the prototypes to the following standard: > > > > ret bool retval can be only 0 or 1 > > nr unsigned long native; signed makes no sense > > addr volatile unsigned long * bitmaps are arrays of ulongs > > > > Finally, add some static assertions in order to prevent people from > > making a mess in this room again. > > I also used the %__always_inline attribute consistently they always > > get resolved to the actual operations. > > > > Suggested-by: Andy Shevchenko > > Signed-off-by: Alexander Lobakin > > --- > > Reviewed-by: Yury Norov > > [...] > > > diff --git a/include/linux/bitops.h b/include/linux/bitops.h > > index 7aaed501f768..5520ac9b1c24 100644 > > --- a/include/linux/bitops.h > > +++ b/include/linux/bitops.h > > @@ -26,12 +26,25 @@ extern unsigned int __sw_hweight16(unsigned int w); > > extern unsigned int __sw_hweight32(unsigned int w); > > extern unsigned long __sw_hweight64(__u64 w); > > > > +#include > > + > > /* > > * Include this here because some architectures need generic_ffs/fls in > > * scope > > */ > > #include > > > > +/* Check that the bitops prototypes are sane */ > > +#define __check_bitop_pr(name) static_assert(__same_type(name, gen_##name)) > > +__check_bitop_pr(__set_bit); > > +__check_bitop_pr(__clear_bit); > > +__check_bitop_pr(__change_bit); > > +__check_bitop_pr(__test_and_set_bit); > > +__check_bitop_pr(__test_and_clear_bit); > > +__check_bitop_pr(__test_and_change_bit); > > +__check_bitop_pr(test_bit); > > +#undef __check_bitop_pr > > This one is amazing trick! And the series is good overall. Do you want me to > take it in bitmap tree, when it's ready, or you'll move it somehow else? Thanks :) Yeah I'm glad we can use __same_type() (-> __builtin_types_compatible_p()) for functions as well, it simplifies keeping the prototypes unified a lot. I'm fine with either your bitmap tree or Arnd's asm-generic tree, so it was my question which I happily forgot to ask: which of those two is preferred for the series. > > Thanks, > Yury Thanks, Olek