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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 219F2C433F5 for ; Fri, 3 Dec 2021 09:20:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8AF2C6B0072; Fri, 3 Dec 2021 04:19:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 85FBA6B0074; Fri, 3 Dec 2021 04:19:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74EA36B0075; Fri, 3 Dec 2021 04:19:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 6740D6B0072 for ; Fri, 3 Dec 2021 04:19:53 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3246A7E373 for ; Fri, 3 Dec 2021 09:19:43 +0000 (UTC) X-FDA: 78875935446.03.ADDCFDA Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id CC708F0000AF for ; Fri, 3 Dec 2021 09:19:42 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B50F362985; Fri, 3 Dec 2021 09:19:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1266C53FCB; Fri, 3 Dec 2021 09:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638523181; bh=w6AlOF3oWeB7nNJxnw3g2UuX2DMssLXJreRdBzLlnrE=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=E9jsGd7sQZwp8MDpZ99QJDa7hmQxepdMiHV78wkuu0h1m93j0OK9lfuQRHOtC1hz6 OC/ipdCuIlynSu+VhAUgnaphHRWYvgatGU0p3DDg3PLIXvvIY0uKafr65eROdmDqEc c2jhwBrMPrbMSdm16q/e/jpxz/7c1tgIX8GtBMy7/AIHiatxHCpLD0NMlI8UuZskIl G8Tn5Hkmg8ZMFbKSznfzVJZyhwRFjmUBBuYRpGIbhme1k4EvRRiw3GiZYT+Wz5mbou YZ5OLo2Lj19eJckw0atUcSHCGYDE44U/G/YMALiD5QiTKWkvw8un3vT5zZWuc44gPf 5hxk35K+brDYQ== From: SeongJae Park To: Andrew Morton Cc: Xin Hao , sj@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND MERGE REQUEST] mm/damon: move damon_rand() definition into damon.h Date: Fri, 3 Dec 2021 09:19:36 +0000 Message-Id: <20211203091936.19804-1-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211202151213.6ec830863342220da4141bc5@linux-foundation.org> X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: CC708F0000AF X-Stat-Signature: yoqobmaqxg69cockp15z7jc6iewt9xjn Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=E9jsGd7s; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1638523182-926339 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, 2 Dec 2021 15:12:13 -0800 Andrew Morton wrote: > On Thu, 2 Dec 2021 15:58:59 +0800 Xin Hao wrote: > > > damon_rand() is called in three files:damon/core.c, damon/ > > paddr.c, damon/vaddr.c, i think there is no need to redefine > > this twice, So move it to damon.h will be a good choice. > > Fair enough. > > > +/* Get a random number in [l, r) */ > > +#define damon_rand(l, r) (l + prandom_u32_max(r - l)) > > This shouldn't be implemented as a macro, for all the usual reasons > (typechecking, side-effects, ugliness, code-documentation site, etc). Yes, agreed. > > In particular, this expression references `l' twice, so calling > > damon_rand(a++, b); > > will increment `a' twice, surprise surprise. Thank you for this nice explanation. > > Can someone please send a followup patch to convert this (and any > similar damon macros) into (probably static inlined) C functions? Sure, I will do, unless someone shows interest here. Thanks, SJ