Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp65022lqc; Thu, 29 Feb 2024 10:22:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU2RX2CSo0Pyd8kiVNSWg6jw0xEeu615lFZt8KJWdM5Vg9Yp2VLoeFijkxqQuM5AE1LH5W9dVod1XHCvHuiV/0cab5ImUFXFbTawan28Q== X-Google-Smtp-Source: AGHT+IFkD5z6CQyyURLkyqOcHkVcX0/P7NTCA8oKdth+S/5H7ZdEu3jz7WFBL1xiTNq+nfiAi44q X-Received: by 2002:a17:902:f7c7:b0:1dc:7890:cb27 with SMTP id h7-20020a170902f7c700b001dc7890cb27mr2885666plw.48.1709230953965; Thu, 29 Feb 2024 10:22:33 -0800 (PST) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id pv16-20020a17090b3c9000b0029b1fe166e3si82370pjb.120.2024.02.29.10.22.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 10:22:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87272-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=X1h7YtHa; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-87272-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87272-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D5F6D2865A2 for ; Thu, 29 Feb 2024 18:22:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 561037C095; Thu, 29 Feb 2024 18:21:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="X1h7YtHa" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85B5E7829E for ; Thu, 29 Feb 2024 18:21:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=192.198.163.7 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709230904; cv=fail; b=BpvF43yBU21TNoeNDbumWU1n+42ELPIyXAewbpW2xu4eQBaIIpYpj6t/WX+mhzVxSHOaSFJ8DPe4vbUIJ7YD5RWx8dutJ6JfQIiFGULuxEQzW9EBiDG66pzd+z+b9WfnXMWW5yUNQQe3H2zBoS4OPDgivq5vR1ZUVG9tBfqyrgA= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709230904; c=relaxed/simple; bh=WMmYmUQEzg0IF20lL2Gpc75dX+zjQMkh9mM5vqY5yFk=; h=Date:From:To:CC:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=LH/ipAVHtVxr52EZsasIgqfnWw3aGrWBc6jjl8ynPx2Rnp30KbTzCEP3HuFKUjlsbafR8foEMiwUEDmKW3JOanFer5pmnfJhnU36rHZ2cT/CLypJ8QlTP9KjHT589/7mx1T0w2GjlnlWYU1cP/ms7cG4pT4FDkttxCRIn3aowUg= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=X1h7YtHa; arc=fail smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709230902; x=1740766902; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=WMmYmUQEzg0IF20lL2Gpc75dX+zjQMkh9mM5vqY5yFk=; b=X1h7YtHa5J5M9YZDIgEI995HWuTwDSAxN5WGb3LrCmDh3ieBC6F96orE ZwOjIk0pA32pgBVNeGlF/+Ps+DgcRem7c3ohzb9EawgY6DdkZpNKX+YNc YK2ry9IW9PBlIUdfBqnNxNi5NHkjdt4Dd7p8SLEcye+lCfMxmxLH7By+7 Q7ApPVYQqBTfS7jR3tc1boKzENp5JLfBNgKYI2qEH0hXfnJnFBDT4fZDJ qNVQIlar4aYIaNICC8Iefa3/UXrVEqJ/VgqohUp7bKoaeq/p+/rADwQgK rT2EQJjC5ac1EXuE5lN5B6zalqKbqNTuz53BEqteqHkvFvuAyGKW1NgFD g==; X-IronPort-AV: E=McAfee;i="6600,9927,10999"; a="29155495" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="29155495" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 10:21:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="12467040" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmviesa005.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 29 Feb 2024 10:21:41 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 29 Feb 2024 10:21:40 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 29 Feb 2024 10:21:39 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Thu, 29 Feb 2024 10:21:39 -0800 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.41) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 29 Feb 2024 10:21:39 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mDI+khmablbaefTEIM7T4wOyOy6uv7/zu/+MVpYUL0Ls1cqoD50zQTZ0SGY7QiVAz/GMKTQqasDYbg3nB+9+raOlYCzWlwyJaU7X8R58d3Bpuly8KoLJ2lpQQgTjU5AD1wHq4VttDgiID/zyf1MYOlk2smuJ5Cpyeda6Z50T9cjboCbyt5lYcvEh+igQEnQfh3POrv+REVx1zv2K8MQslkhz27NCrnZbf8/XGN3mhyt0PztOjc7XopPDaEDUBcjJQJ0tVMe/dyCGhmeGRpeE/QsDZRp5dlPSVySJXIGmAqVoyH7UH8YOUyzinETYi0JNuDIcMnKn2MaNlEEZZV57Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jSAwAu3QioTUOxs+FsuAe61M0nWzC0r5Chfjnx4erDg=; b=aDAjj53StrilfoweBL7a4/rf6j8n+2+s5JR552yLXYMnkTAU1NU3aWJZAsD4y2Pse0chNiMxcBk67OYV85jKtzBJ9KUU/KyuXzF0NEBeEbOGEkQdkcvxTsg/6zR92b/OJn58r7n/1xoIKN1Fkq83dLTWs6haW/FUbbvkrAM48eRch4Q6oc4l0BVF2WmfjC33LcxShh6yvEn15HqjpGyUeuueayPslKNmyRTE4kdiPOd4mNLrYCVlTgvM1Nd/74MWu0dT3wSpXwTo0mI7DGcfEu4OmntVnebFTh9Yr0rCvFssOONH6QqdOF1TZbJmB8dlUEBy6gYneE0gNmFKXgM1yA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from CY5PR11MB6139.namprd11.prod.outlook.com (2603:10b6:930:29::17) by SA3PR11MB8073.namprd11.prod.outlook.com (2603:10b6:806:301::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.23; Thu, 29 Feb 2024 18:21:37 +0000 Received: from CY5PR11MB6139.namprd11.prod.outlook.com ([fe80::7352:aa4b:e13e:cb01]) by CY5PR11MB6139.namprd11.prod.outlook.com ([fe80::7352:aa4b:e13e:cb01%7]) with mapi id 15.20.7339.024; Thu, 29 Feb 2024 18:21:37 +0000 Date: Thu, 29 Feb 2024 12:21:34 -0600 From: Lucas De Marchi To: Andy Shevchenko CC: Yury Norov , Dmitry Baryshkov , , , Jani Nikula , , , "Jani Nikula" Subject: Re: [PATCH v3 1/3] bits: introduce fixed-type genmasks Message-ID: References: <20240208074521.577076-1-lucas.demarchi@intel.com> <20240208074521.577076-2-lucas.demarchi@intel.com> <3o3nvkg76sofrhgcuogo3wuhitnz3bgus6qzle7pejng3v4s62@frdbuj46uiu7> Content-Type: text/plain; charset="us-ascii"; format=flowed Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SJ0PR13CA0208.namprd13.prod.outlook.com (2603:10b6:a03:2c3::33) To CY5PR11MB6139.namprd11.prod.outlook.com (2603:10b6:930:29::17) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR11MB6139:EE_|SA3PR11MB8073:EE_ X-MS-Office365-Filtering-Correlation-Id: 9abe1c42-4ea5-45c9-d6a5-08dc39534447 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xr4ZBYXnqONLd6mt78wi1B3yRk0eewJ+Fumf0SbiIw+6SWlKCq67yOUritFJQ2Ih51ujuCFcHYK7WATmlyMBx4c0AZ9SQBT+GTqX7eWYS24CV80kA2LjofNwZdHs5L40onDEeiYoS99CxELGgI1k62zGQ31DvY9j+c4jXkQ8rGDKKr8ZpfsGJrO6Ovw/SjTa2Adg/PVEKL1A8m0jTnl1A/sWGPDtO3F2oNTldqmr9ddK+BpAarVWbQKwnmWDnOCTdWJPYdCsbrbjZRMv50iWjiDJyjqUpQU+m5TtV67p9Hb8B/XuORdDKrFQITSMgpdU+KPk0PpkJPvBv2ELMg+InFVjLBerNBP1blClcumOIes5BrgFv8f/0X6fY5NJYZzgzkQRVK3KtciQcyM0uSIu4D+o5FkZJgxwDVa+SBHtziyUqwIKdHpTYpIQE3tjR7Ei6U0K6F8UlxKzgYYv3aV3xgK6Q8cPFhHYLUPrzCsN+x+0uWUCuPBx8G7kI5FwFgYu30e+/XqR/7uRVzT9zSm8Iz0jZmaL/U8qugEDcqyEa9dj4czEgsXLWc0jmf+715xMLEB3E0nfYX3G2TFn1y+VE+dGudx3DMrxj+dtxlXKiIJDaaNrtEvCgx3m+EXqsRbfOy0nf1KPRNd0nzp0G5Rtzw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR11MB6139.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?gkg04ObwN1Jn6GnQKbHHyZAeiPFVuy3XL+iKmwZp/irKgAIPfAVTuNJovU4v?= =?us-ascii?Q?TslScLpSlwqbzbYKe3PL7xRKAgWQZmCjRxqqc64kec4VIqY+h7b80MxU5SW4?= =?us-ascii?Q?w3qNU6UcIiF3dTvRb8wrQ4xCgIeRNTtRzhy+Dewg5DD/QNce7AVvz85jspIE?= =?us-ascii?Q?Xj0hokC4XhqwwEFYc4WafX2f3qwj89wkhaMlK8ERV2eAS1oU/Jrb03rYnTjH?= =?us-ascii?Q?hcND5zLJn3oyEqPOU+2OEM8SzIBBGSvlsmzSYrm8xhghvnczGtjybRp2+fOY?= =?us-ascii?Q?aq/vLE0JF9BOpl8MLuSLxmRr2cQNVlEW9xmgANG1jfBBQrfZsc6mf4mO3Liy?= =?us-ascii?Q?6aqC0mfDbqqA+tu6TQbyd5JC7wZ3JnCHzPxWpO4aVOCsf6LWAXKKKQ9YetLR?= =?us-ascii?Q?u/CUbn+EIzX112HjV3jg2D7vR86z5wFdp3spZVKSUZLlk60yibXvx5XnerR2?= =?us-ascii?Q?RlOBlGVPjHF8i5mSqEahnhj6VBxsA3Ax+CEvHZbriesfGizpjyx2G9Wu0Mkz?= =?us-ascii?Q?lqhwHAtWwoqiA7vevF9owoDAzXu4ZD6kx0v2M8fTrjetSUrmEgXkx2tPAl7+?=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1ee3kZUBxTOezucdh0xFxMwkC?= =?us-ascii?Q?qIrweJpK+oUx76kf5z26q0St03TzAZrzIfScqJaqUbaAmaavRzczErjBNNfe?= =?us-ascii?Q?E+MGYoakdXtjkAufhoyDCvXHpm5xTP4lbYmxLQtMZILZLlc0GwwVqF8sgx1H?= =?us-ascii?Q?zg=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 9abe1c42-4ea5-45c9-d6a5-08dc39534447 X-MS-Exchange-CrossTenant-AuthSource: CY5PR11MB6139.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Feb 2024 18:21:37.2827 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RosUVLRyICWc7NG8fuQi1m585h4jg9pCb7rdiRVmDI7FwFmxNw6SsnA6RwxGjkw3JYbKJuWwdTJQX6KwRYZMiURW+0C6R0CfqaUPh4mfcg8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR11MB8073 X-OriginatorOrg: intel.com On Thu, Feb 29, 2024 at 12:49:57PM +0200, Andy Shevchenko wrote: >On Wed, Feb 28, 2024 at 05:39:21PM -0600, Lucas De Marchi wrote: >> On Thu, Feb 22, 2024 at 06:49:59AM -0800, Yury Norov wrote: >> > On Wed, Feb 21, 2024 at 03:59:06PM -0600, Lucas De Marchi wrote: >> > > On Wed, Feb 21, 2024 at 11:04:22PM +0200, Andy Shevchenko wrote: >> > > > On Wed, Feb 21, 2024 at 10:30:02PM +0200, Dmitry Baryshkov wrote: >> > > > > On Thu, 8 Feb 2024 at 09:45, Lucas De Marchi wrote: > >... > >> I build-tested this in x86-64, x86-32 and arm64. I didn't like much the >> need to fork the __GENMASK() implementation on the 2 sides of the ifdef >> since I think the GENMASK_INPUT_CHECK() should be the one covering the >> input checks. However to make it common we'd need to solve 2 problems: >> the casts and the sizeof. The sizeof can be passed as arg to >> __GENMASK(), however the casts I think would need a __CAST_U8(x) >> or the like and sprinkle it everywhere, which would hurt readability. >> Not pretty. Or go back to the original submission and make it less >> horrible :-/ > >I'm wondering if we can use _Generic() approach here. in assembly? > >... > >> > #define GENMASK_INPUT_CHECK(h, l) 0 >> > +#define __GENMASK(t, h, l) \ >> > + ((~0 - (1 << (l)) + 1) & (~0 >> (BITS_PER_LONG - 1 - (h)))) >> >> humn... this builds, but does it work if GENMASK_ULL() is used in >> assembly? That BITS_PER_LONG does not match the type width. > >UL()/ULL() macros are not just for fun. they are not for fun, but they expand to a nop in assembly. And it's up to the instruction used to be the right one. Since this branch is for assembly only, having them wouldn't really change the current behavior. I'm talking about BITS_PER_LONG vs BITS_PER_LONG_LONG. That introduces a bug here. Lucas De Marchi > >-- >With Best Regards, >Andy Shevchenko > >