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 823C8C433EF for ; Fri, 14 Jan 2022 22:10:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 160EE6B017F; Fri, 14 Jan 2022 17:10:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 10FEE6B0181; Fri, 14 Jan 2022 17:10:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F40C16B0182; Fri, 14 Jan 2022 17:09:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id E24276B017F for ; Fri, 14 Jan 2022 17:09:59 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B0C3A1823021C for ; Fri, 14 Jan 2022 22:09:59 +0000 (UTC) X-FDA: 79030286118.18.A1993AC Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf07.hostedemail.com (Postfix) with ESMTP id 5E77140005 for ; Fri, 14 Jan 2022 22:09:59 +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 ams.source.kernel.org (Postfix) with ESMTPS id 4B5DFB82A3A; Fri, 14 Jan 2022 22:09:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C04C8C36AEC; Fri, 14 Jan 2022 22:09:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1642198197; bh=ylEN43liLL2VFwNC4OUZNmfMB4yZIT74JoAXom6JfQI=; h=Date:From:To:Subject:In-Reply-To:From; b=lyWyKKMGMxRHkoeUq3Fx5DJs0tf9V1KIq2yxYa2eT734/mukiN0sCrp7dBjDfZx1y cnNkbxGBwj4ll3jQwgroK7DuK3NIhYfw3+P0YVZQpOvdpQmflqA04skTJVJ9YOZAxQ +ohPlJs73PzwSxzW63dE7Fb2+iro+RW0/uTiMB8M= Date: Fri, 14 Jan 2022 14:09:56 -0800 From: Andrew Morton To: akpm@linux-foundation.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, sj@kernel.org, torvalds@linux-foundation.org, xhao@linux.alibaba.com Subject: [patch 128/146] mm/damon: modify damon_rand() macro to static inline function Message-ID: <20220114220956.eFS-asqP9%akpm@linux-foundation.org> In-Reply-To: <20220114140222.6b14f0061194d3200000c52d@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5E77140005 X-Stat-Signature: herd876m7ujd8hp1rqfbsj3n6zy79fqy Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=lyWyKKMG; spf=pass (imf07.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1642198199-406361 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: From: Xin Hao Subject: mm/damon: modify damon_rand() macro to static inline function damon_rand() cannot be implemented as a macro. Example: damon_rand(a++, b); The value of 'a' will be incremented twice, This is obviously unreasonable, So there fix it. Link: https://lkml.kernel.org/r/110ffcd4e420c86c42b41ce2bc9f0fe6a4f32cd3.1638795127.git.xhao@linux.alibaba.com Fixes: b9a6ac4e4ede ("mm/damon: adaptively adjust regions") Signed-off-by: Xin Hao Reported-by: Andrew Morton Reviewed-by: SeongJae Park Signed-off-by: Andrew Morton --- include/linux/damon.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/include/linux/damon.h~mm-damon-modify-damon_rand-macro-to-static-inline-function +++ a/include/linux/damon.h @@ -19,7 +19,10 @@ #define DAMOS_MAX_SCORE (99) /* Get a random number in [l, r) */ -#define damon_rand(l, r) (l + prandom_u32_max(r - l)) +static inline unsigned long damon_rand(unsigned long l, unsigned long r) +{ + return l + prandom_u32_max(r - l); +} /** * struct damon_addr_range - Represents an address region of [@start, @end). _