Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp481881lqh; Fri, 31 May 2024 07:20:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVQz8FpsPRGJelLH++14dtBqsHnpAZkrcrzZv64qstoqz1gDSNC32M8eCxFY71g8FrS1dO5KLGpBkNs6qLyLKqX1HYJF0ll8y5CcUDKjw== X-Google-Smtp-Source: AGHT+IHrd17fzR9fr9fjgiDkG1lEOHAXwmXW/EnWVcUMdt15HQOc0HvFZ0RM4ncpDxq/O/Yxox0e X-Received: by 2002:a17:903:40c2:b0:1f6:2ab1:6033 with SMTP id d9443c01a7336-1f636fe8709mr21297315ad.8.1717165238325; Fri, 31 May 2024 07:20:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717165238; cv=pass; d=google.com; s=arc-20160816; b=Co03o6hfmH1UbCYJcW1qVas273wCmWTZvphpjTYujdAyHcgSgx5gT9nZecbwRFS+zL ljmc9XZzNhhgzPacT0O5DWROMmQQQK1Pr5iLZBcYgryrgIR7s8SmF+YLsM3wMTVd6Wrt G4cxpGfSC5Eh1z9Lz1uZLKyr6TegjI2ZGonVzXjUfKPWhM2M0w7vfBJC+YOHi3YQ+qgZ h/t1xFNxxnrXsRwo+NuMG3pSyckPFVIJiICMtJK+ughBQWk6iPAJhZeMXqr+niurItGg 8qDKJ6yAMZPbFaHnFMwVT3OQ0KlbQsyfIjjlQuZCfUGTOM2ss++WA9tdEl4WrtMnEzVf Pddw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=e5/RtIqYjKcE2A3uyUfwm4AdnYlKXf8+OQBnrHpxDqg=; fh=Rn7ybkpAD5ahhJST+s2XCPKKQGU7d9Qyjx8ZXaGsEO0=; b=PBsQdlo4hiBCu9kNboshEgICnqzyK73stTqtM6zEIJ8OlAoVcM3NYzdN4g+GbOUw8J 2Z5zvgX7x15mbjxpxFONA4v33trN8HllyFF3cU1GV1g6w7BX8mHQQdFO/bFJ4ZCT98TU E7pgklpmdNxp4IieOA+/iwIRfcMUYnTtnwRrZOwJ8xlCbiqJS9sYqzn0eOTAHwWz8qXm V5zl8S+NE0/GMvHmkykU50XsuWoS5b8qrJwSG9ENMWISMxHgtR6TQt6+/P8Az4vECzMM /gA0BFNRW0MyFSEYccVAHzWKQ1J5iFDWJoNgPX5TAFeNCH1yfz5wwyfqPgdvcRg1IWzA kx9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nH1rEpv6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196942-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196942-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6342c6a9esi15112375ad.312.2024.05.31.07.20.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 07:20:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196942-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nH1rEpv6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196942-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196942-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 6B6E128AF68 for ; Fri, 31 May 2024 14:04:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69D0C15CD69; Fri, 31 May 2024 14:04:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nH1rEpv6" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 88E7615AAB6; Fri, 31 May 2024 14:04:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717164283; cv=none; b=brikfm0nH3LT7A8ePvZWO5OMEGE/+tfWAtevoavFXtzMf3ovp+9F2UGUlTcl+OL2Y2W3bL1bnmNh45FkiSkpym/e7+jWQlX7OcxVhdxzq1EB6bxjaEpeRbzs9G3Uo2jRvUDap8RyRItdjgj8qK91XFpEynSCpdH/RCA97q8VZ0g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717164283; c=relaxed/simple; bh=b5qIPlknK8jeWDh3WleCY1vRy0w4FGugICdq2Y4YMvM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bX73YZsVLZ9z/QxvSRkdaxKfCJnhQ8lW91r75C2pgyA0ZnFmad+z3HXnhWpF9HH3MtDzd6awuO1doucnFG3Z4os9OPyYpSy0ndL0MuDGE1N0N1fgsA9w9sqY17tMsIV/8Fwf+74RocVyRw7t4ctQNXtBQh6s3k+KDkTRTx5/CNw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nH1rEpv6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22FC9C116B1; Fri, 31 May 2024 14:04:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717164283; bh=b5qIPlknK8jeWDh3WleCY1vRy0w4FGugICdq2Y4YMvM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nH1rEpv61HPwulSaOR9famkQ9Xic/cw0ly3cU/keRssOQgODRyvAQ8PV7WBD87yXU cFaFlfhSjKPQXGoNF1Zu94DAx40IXm2wtejn87Tvd+367xlR+fpKgCMu+88M2hdoLo 986X5yaH4gi3KaZVPOZ+5b/zpWKOli1UvgsNSLXqEz3zZxYThmHgfhkUvDYPPHARJs PnY16UKVc9dfmQMLhvt/ZhJWQaz6gkxa3qSF1pm7lgMYaUdFvRvsDZD/LM2Teie5D6 4Iu2Dwzc3/3/vJ3ju+2RoVpW02Srb29a9VzpvZ2oa/Un5KVIBm5l85gP1JGqn+LH0k 2QziNQ48nuVXw== Date: Fri, 31 May 2024 07:04:42 -0700 From: "Darrick J. Wong" To: Zhang Yi Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, hch@infradead.org, brauner@kernel.org, david@fromorbit.com, chandanbabu@kernel.org, jack@suse.cz, willy@infradead.org, yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: Re: [RFC PATCH v4 2/8] math64: add rem_u64() to just return the remainder Message-ID: <20240531140442.GG52987@frogsfrogsfrogs> References: <20240529095206.2568162-1-yi.zhang@huaweicloud.com> <20240529095206.2568162-3-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240529095206.2568162-3-yi.zhang@huaweicloud.com> On Wed, May 29, 2024 at 05:52:00PM +0800, Zhang Yi wrote: > From: Zhang Yi > > Add a new helper rem_u64() to only get the remainder of unsigned 64bit > divide with 32bit divisor. > > Signed-off-by: Zhang Yi Modulo hch's comments, Reviewed-by: Darrick J. Wong --D > --- > include/linux/math64.h | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/include/linux/math64.h b/include/linux/math64.h > index d34def7f9a8c..618df4862091 100644 > --- a/include/linux/math64.h > +++ b/include/linux/math64.h > @@ -3,6 +3,7 @@ > #define _LINUX_MATH64_H > > #include > +#include > #include > #include > #include > @@ -12,6 +13,20 @@ > #define div64_long(x, y) div64_s64((x), (y)) > #define div64_ul(x, y) div64_u64((x), (y)) > > +/** > + * rem_u64 - remainder of unsigned 64bit divide with 32bit divisor > + * @dividend: unsigned 64bit dividend > + * @divisor: unsigned 32bit divisor > + * > + * Return: dividend % divisor > + */ > +static inline u32 rem_u64(u64 dividend, u32 divisor) > +{ > + if (is_power_of_2(divisor)) > + return dividend & (divisor - 1); > + return dividend % divisor; > +} > + > /** > * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder > * @dividend: unsigned 64bit dividend > @@ -86,6 +101,15 @@ static inline s64 div64_s64(s64 dividend, s64 divisor) > #define div64_long(x, y) div_s64((x), (y)) > #define div64_ul(x, y) div_u64((x), (y)) > > +#ifndef rem_u64 > +static inline u32 rem_u64(u64 dividend, u32 divisor) > +{ > + if (is_power_of_2(divisor)) > + return dividend & (divisor - 1); > + return do_div(dividend, divisor); > +} > +#endif > + > #ifndef div_u64_rem > static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) > { > -- > 2.39.2 > >