Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2093872lqt; Mon, 22 Apr 2024 00:46:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV+cECv2vhNJHxhJgbjL/kh7l8xIUcfWDz8NRxnH4pGeaEVMA3XcDS8pp4ru7E/V8hr2OPJObWegzJHJ5F7oPYn4w1Bpy/6ko+asbsCrQ== X-Google-Smtp-Source: AGHT+IGoJPYdyH3SJkklKGwWMxuYryJ6/2U2jjV5RYg1iuOhciaCdbXEP8lvK0wGIMi2SBJqMapc X-Received: by 2002:a05:6122:1d53:b0:4da:d4ec:962f with SMTP id gd19-20020a0561221d5300b004dad4ec962fmr6463558vkb.9.1713771960887; Mon, 22 Apr 2024 00:46:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713771960; cv=pass; d=google.com; s=arc-20160816; b=pEg/avW8WJUAIEJJRhIK3ZLFnA3ZC4ulpOKHny4ym8VU9yCHr1U5AfiHN6XWLkWmiD hRwhVUEsZwfPxT1ELj2Jq3M5Z5XAPZfy5UEbmsObhlib+QPsR6UGwxEvOiDgljkTtZzg k+ULIoISU+3gCQDxFeW57Epkoy9eITEOXgDpjlMP9DVeFol4ef/V/DWnlTu/+DHwBhMq yYGjbxfcskPzdX1cINiNSBMj5/5Q4m2LtuRN2wD6u5NI0Z6StuRIGdHeS+2Ea1DCF+ZK g8+Jzpp1t2/7sm4v5snEe1iNJOr5/vw+JVhs+zAjvWGYr6LsI4WsWRgALoGyol2p4fJg mXWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=y0a14qG6TZpbv5hO/uzBHqzZVoFvluryleHwsj8N3us=; fh=O+7Zpr1Qf1YYes/oHo7ZuccAJvv4Y9VTGL47p3xpGU8=; b=nv89SSigq8LOqPMkeAvzcD12P9rQWJu/+RJo4cTaDs7a2rYptPHBXL4SM3og97uJat GOe+x2+MNZ8LV/DX9mj8MhAX5j1j8LPwL150aNQFqQ5Gan8ww9sxl2k3YxBtsXHX9GDc Qg/UvfB+pn0Lwd2nefUS567Moo1gMHKrqAZqrNwJgIFt04DfvesO4NxbP7Wd7KAEZ88Q 90tiQhItG8PjYWy3DirEczn6dhlW+837OiAK1jBiOnttBAfe6+UMhaO08gmfAag4q0/E 47Cm8NggT+4KCtyO0jEBUq9veVzhfJC2Yh3cL4CaABj6BEo4aCrfXTsK+BrdNelrMubJ /tAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hat8fmfN; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-152895-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152895-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o6-20020a05620a228600b0078d6085f5easi9607240qkh.304.2024.04.22.00.46.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 00:46:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152895-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hat8fmfN; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-152895-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152895-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 906281C210CD for ; Mon, 22 Apr 2024 07:46:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A5495029D; Mon, 22 Apr 2024 07:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hat8fmfN" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 CD76B4AEDA; Mon, 22 Apr 2024 07:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713771888; cv=none; b=eSOYpXHX/l12zLuSrxqgOwt5INzTtFnN67BPm1gyTgx+bCctPbmcVPms8C+FLQEDPEhHGJVODKY3oKX/NiUZeba/EWMNQQyoViyg2l1vf5kBVD0enZ70VQ2aRAQ1Uw7CVZ8OA2pKiwmPCKDczFUpJXVnr6OI5Ah8q/kuRr1SpW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713771888; c=relaxed/simple; bh=DJBrn7TxHiTduPF1HXr+JJpm5dsFnOdnOeFDvVQw2tE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=d9hiyXZwc7r/JLHjXZpDst0GOFB018Zr2jDtABaqS9eSY2hFpVxdizGEls4nSwtLplgGod8m+WGG1DHoYhl7vfNpcXdUzhO5Y7WjuBYXze48/LjDdAwIrlh5gt1GPrDrRrEBkZFdFUQ0dMberntfMSNoND+oAipTGKF6+Wl6jFA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hat8fmfN; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713771887; x=1745307887; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=DJBrn7TxHiTduPF1HXr+JJpm5dsFnOdnOeFDvVQw2tE=; b=hat8fmfNh0y92N/22PVTSy+xVtkrlDfjw+wvzlaso8sp1KaMoxWTQKvC 72jywUSoBX8kvcr4xIB+RFFUlwOt9z3IyNJt0Z6D94PQyl0ialdhKiiJF j26XtkVwDHhTn5aIBwd4P6r2KM1kFTa+zvkk2IEfh2gZbU8CEcvAfDJgR GtqOABXJGM+5VNYe6zfSn+2c7yADpO64t05PHO9jab7rHtHI/r7OWEf5n Cwn5I3tOhFgIuka3hMqzrbdFjeLUDm4CA1RchxsbqakoRL36KUbkgIWi3 8jcYbh1r2Ztxqw+VpChL9EpdjnlTdWwQS2VFYferh22NDcqZlJHv2bIhK A==; X-CSE-ConnectionGUID: ARl9/nURSQi2QzLBZA00EA== X-CSE-MsgGUID: E4iARbZZRwKVGWRKWDjUug== X-IronPort-AV: E=McAfee;i="6600,9927,11051"; a="13132548" X-IronPort-AV: E=Sophos;i="6.07,220,1708416000"; d="scan'208";a="13132548" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2024 00:44:46 -0700 X-CSE-ConnectionGUID: vCbpEgAXTp6FHliHTka3Sw== X-CSE-MsgGUID: DgEm0hL5THmtu2dfTPXBGg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,220,1708416000"; d="scan'208";a="23959026" Received: from aslawinx-mobl.ger.corp.intel.com (HELO [10.94.8.107]) ([10.94.8.107]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2024 00:44:43 -0700 Message-ID: <42e6a510-9000-44a4-b6bf-2bca9cf74d5e@linux.intel.com> Date: Mon, 22 Apr 2024 09:44:40 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] bitops: Change function return types from long to int Content-Language: en-US To: Thorsten Blum , Arnd Bergmann Cc: Xiao Wang , Palmer Dabbelt , Charlie Jenkins , Namhyung Kim , Huacai Chen , Youling Tang , Tiezhu Yang , Jinyang He , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240420223836.241472-1-thorsten.blum@toblux.com> From: =?UTF-8?Q?Amadeusz_S=C5=82awi=C5=84ski?= In-Reply-To: <20240420223836.241472-1-thorsten.blum@toblux.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/21/2024 12:38 AM, Thorsten Blum wrote: > Change the return types of bitops functions (ffs, fls, and fns) from > long to int. The expected return values are in the range [0, 64], for > which int is sufficient. > > Additionally, int aligns well with the return types of the corresponding > __builtin_* functions, potentially reducing overall type conversions. > > Many of the existing bitops functions already return an int and don't > need to be changed. The bitops functions in arch/ should be considered > separately. > > Adjust some return variables to match the function return types. > > With GCC 13 and defconfig, these changes reduced the size of a test > kernel image by 5,432 bytes on arm64 and by 248 bytes on riscv; there > were no changes in size on x86_64, powerpc, or m68k. > > Signed-off-by: Thorsten Blum > --- > include/asm-generic/bitops/__ffs.h | 4 ++-- > include/asm-generic/bitops/__fls.h | 4 ++-- > include/asm-generic/bitops/builtin-__ffs.h | 2 +- > include/asm-generic/bitops/builtin-__fls.h | 2 +- > include/linux/bitops.h | 6 +++--- > tools/include/asm-generic/bitops/__ffs.h | 4 ++-- > tools/include/asm-generic/bitops/__fls.h | 4 ++-- > tools/include/linux/bitops.h | 2 +- > 8 files changed, 14 insertions(+), 14 deletions(-) I don't mind the idea, but in the past I've send some patches trying to align some arch specific implementations with asm-generic ones. Now you are changing only asm-generic implementation and leaving arch specific ones untouched (that's probably why you see no size change on some of them). For example on x86, there is: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/include/asm/bitops.h?id=ed30a4a51bb196781c8058073ea720133a65596f#n293 and you probably need to check all architectures for those implementations. Thanks, Amadeusz