lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20231116105817.51824-1-sj@kernel.org>
Date:   Thu, 16 Nov 2023 10:58:17 +0000
From:   SeongJae Park <sj@...nel.org>
To:     FANG2508 <1031576200@...com>
Cc:     linux-mm@...ck.org, sj@...nel.org, linux-kernel@...r.kernel.org,
        damon@...ts.linux.dev
Subject: Re: [PATCH] mm/damon/ops-common.c: Fixup missing parentheses

Hello FANG2508,

On Thu, 16 Nov 2023 18:21:47 +0800 FANG2508 <1031576200@...com> wrote:

> In function 'damon_hot_score', the variable 'hotness' should be divided by the sum of 'freq_weight' and 'age_weight' instead of /'freq_weight'+'age_weight'.
> 
> Signed-off-by: FANG2508 <1031576200@...com>
> ---
>  mm/damon/ops-common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
> index d25d99cb5f2b..fc7886c63bf1 100644
> --- a/mm/damon/ops-common.c
> +++ b/mm/damon/ops-common.c
> @@ -102,7 +102,7 @@ int damon_hot_score(struct damon_ctx *c, struct damon_region *r,
>  
>  	hotness = (freq_weight * freq_subscore + age_weight * age_subscore);
>  	if (freq_weight + age_weight)
> -		hotness /= freq_weight + age_weight;
> +		hotness /= (freq_weight + age_weight);

Thank you for this patch.  However, I think the old code is ok, since the
precedence of the /= operation is right to left[1]?  I also checked that's true
by confirming below simple kunit passes.

    int abc = 3;

    abc /= 1 + 2;
    KUNIT_EXPECT_EQ(test, abc, 1);

Please let me know if I'm
missing something.


[1] https://en.cppreference.com/w/c/language/operator_precedence


Thanks,
SJ

>  	/*
>  	 * Transform it to fit in [0, DAMOS_MAX_SCORE]
>  	 */
> -- 
> 2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ