Message ID | 20240126085905.2835513-1-yajun.deng@linux.dev |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-39865-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp550880dyb; Fri, 26 Jan 2024 01:52:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGuWpd3S4Bl00WaSp9KrThypob//wvrkNexlsn8d7yvpzWY4xk4/np0c3Oqt5iKdZgpxhA5 X-Received: by 2002:a17:906:3b52:b0:a34:d426:1beb with SMTP id h18-20020a1709063b5200b00a34d4261bebmr661892ejf.54.1706262757686; Fri, 26 Jan 2024 01:52:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706262757; cv=pass; d=google.com; s=arc-20160816; b=t3cOrqymYg+GSexSXrD8pZw8TGa+qfBrGBcW6SxsXAtN+pN/aq8/NvykZ3sfbhc+gw ZYzpaoZhXvDFTXunou+hwZT3uDwt/UKYoIC7j3xHl34QvfMrrdWVEPIgbOXnrOP/i3Gj Zg/e6hOXFF/hrHcdMoCrKv2RQyyySi/3CyM+jUiVgIXhyP+FX2Yoy/vy61MVHGUq1PGa 0zj3RDwn93YtttOWKGeSfCRWBbrS2nYuSBduafQp/PYeeF2xS5wbRdNK5U6N8hYiEZjP rzkejJLiyykuwM+Z0K1IvFHRwcBG3qoCTuycWXw1sqOG2IBCAfO/nyQmwBSfFImwSg7+ MkOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=UEiYHt6EA6JI2A3oFzAKFbfq5nte6C1ofdfTW06tbP8=; fh=KPJjYJHLC+uLVMTRQa7GdG2CYCH/otyIF0MYaE50dhE=; b=Qyo/fs4ZIc7C+7e9nkaQy0MXnBGRR2qG3bm0XYtRsnoV5SUmta3T5D+iK+SxyQDGsk gfTrTKftqjk0E6TYwOdpUEOTd256hN4BOasdGztNUxS4qGhyPYBii/4FDkRJGr3MaCHD bV7mo8q8ALwM/oNKf+im6r44Q2dUSXWY81aAffQ5JCpRw4Nk5G+kekiRPQujDT2ctwLE xTBsP+rL6kfzh2THnaLANoJvtAUzFXm/EDp2yFFWegOPmaxPlgl+qHbuB3PK2m0vj67S 00cPQ37gRbuSajxi1LpTDovSEu0mcmjvxs6MNe25XitQmYX4eFRZEv1pZXzH9p62XWex Eo1Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=hZaTYq6y; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-39865-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39865-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x4-20020a170906b08400b00a3178e6cfb6si427628ejy.855.2024.01.26.01.52.37 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 01:52:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39865-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=hZaTYq6y; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-39865-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39865-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id EAF6D1F301DF for <ouuuleilei@gmail.com>; Fri, 26 Jan 2024 09:50:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37E87153BC4; Fri, 26 Jan 2024 08:59:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="hZaTYq6y" Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 C59C150A83 for <linux-kernel@vger.kernel.org>; Fri, 26 Jan 2024 08:59:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706259564; cv=none; b=VRQvrlpPCdj9MXviaVch/Ry/aXRRpqbktkNIQlKPFeBguuZQ4EiSJ2OJw+gxwhKNu4l57gfLX2XCClZchBkmK6mby2EtXfkJcmuJPVpqSOD2K0ugkQ7y9Ol8GuNYNjRbDwq5h0+kfzsFVR6chSKV542PPPQKbuatypjzFPtLm6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706259564; c=relaxed/simple; bh=836H8CGuHwNWoT8y45F3p7ZGOUU+Or9lzM4KtbucyVI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=sShKV55zVqHWYp90qLU3hOTarktDtTC1HVazSczblP+6lL0RPqFRCsXRdBvmT8KvoVF/39VGccGfx2/MsMCvMR/1t1Tq36zPCbrwI4fa8RH6OJG3xziO9lzFEoOcwQpWkMZCNxaEYJuGIuV+NN3fvRH4yFG+qSb0uGjG4quzhvc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=hZaTYq6y; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1706259559; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=UEiYHt6EA6JI2A3oFzAKFbfq5nte6C1ofdfTW06tbP8=; b=hZaTYq6yORpyB61XP6FMuKwBdf5riISYuB3djvq9huZIB+zXVjpCYtDIbBToipBg9QPfet CYsKkoucQO52QVjWiED1IvybA9EJBl5Or/kkOqLNp40LRro9eS0hDb+jFjPzQfPdSiwIyM +RiZki+Mn0KsyOk3pt7xvKYoflnmRGE= From: Yajun Deng <yajun.deng@linux.dev> To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yajun Deng <yajun.deng@linux.dev> Subject: [PATCH] mm/mmap: use SZ_{8M, 128M} helper macro Date: Fri, 26 Jan 2024 16:59:05 +0800 Message-Id: <20240126085905.2835513-1-yajun.deng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789146177540565257 X-GMAIL-MSGID: 1789146177540565257 |
Series |
mm/mmap: use SZ_{8M, 128M} helper macro
|
|
Commit Message
Yajun Deng
Jan. 26, 2024, 8:59 a.m. UTC
Use SZ_{8M, 128M} macro intead of the number in init_user_reserve and
reserve_mem_notifier.
Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
mm/mmap.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
On Fri, Jan 26, 2024 at 04:59:05PM +0800, Yajun Deng wrote: > Use SZ_{8M, 128M} macro intead of the number in init_user_reserve and > reserve_mem_notifier. > > Signed-off-by: Yajun Deng <yajun.deng@linux.dev> > --- > mm/mmap.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/mm/mmap.c b/mm/mmap.c > index 476de5daf598..f90924b2a6d2 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -3845,7 +3845,7 @@ static int init_user_reserve(void) > > free_kbytes = K(global_zone_page_state(NR_FREE_PAGES)); > > - sysctl_user_reserve_kbytes = min(free_kbytes / 32, 1UL << 17); > + sysctl_user_reserve_kbytes = min(free_kbytes / 32, SZ_128M); (1UL << 17) != SZ_128M > return 0; > } > subsys_initcall(init_user_reserve); > @@ -3866,7 +3866,7 @@ static int init_admin_reserve(void) > > free_kbytes = K(global_zone_page_state(NR_FREE_PAGES)); > > - sysctl_admin_reserve_kbytes = min(free_kbytes / 32, 1UL << 13); > + sysctl_admin_reserve_kbytes = min(free_kbytes / 32, SZ_8M); > return 0; > } > subsys_initcall(init_admin_reserve); > @@ -3898,12 +3898,12 @@ static int reserve_mem_notifier(struct notifier_block *nb, > case MEM_ONLINE: > /* Default max is 128MB. Leave alone if modified by operator. */ > tmp = sysctl_user_reserve_kbytes; > - if (0 < tmp && tmp < (1UL << 17)) > + if (tmp > 0 && tmp < SZ_128M) > init_user_reserve(); > > /* Default max is 8MB. Leave alone if modified by operator. */ > tmp = sysctl_admin_reserve_kbytes; > - if (0 < tmp && tmp < (1UL << 13)) > + if (tmp > 0 && tmp < SZ_8M) (1UL << 13) != SZ_8M > init_admin_reserve(); > > break; > -- > 2.25.1 > >
On 2024/1/30 17:11, Mike Rapoport wrote: > On Fri, Jan 26, 2024 at 04:59:05PM +0800, Yajun Deng wrote: >> Use SZ_{8M, 128M} macro intead of the number in init_user_reserve and >> reserve_mem_notifier. >> >> Signed-off-by: Yajun Deng <yajun.deng@linux.dev> >> --- >> mm/mmap.c | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/mm/mmap.c b/mm/mmap.c >> index 476de5daf598..f90924b2a6d2 100644 >> --- a/mm/mmap.c >> +++ b/mm/mmap.c >> @@ -3845,7 +3845,7 @@ static int init_user_reserve(void) >> >> free_kbytes = K(global_zone_page_state(NR_FREE_PAGES)); >> >> - sysctl_user_reserve_kbytes = min(free_kbytes / 32, 1UL << 17); >> + sysctl_user_reserve_kbytes = min(free_kbytes / 32, SZ_128M); > (1UL << 17) != SZ_128M I am sorry for this, I didn't realize that the unit was kbyte. > >> return 0; >> } >> subsys_initcall(init_user_reserve); >> @@ -3866,7 +3866,7 @@ static int init_admin_reserve(void) >> >> free_kbytes = K(global_zone_page_state(NR_FREE_PAGES)); >> >> - sysctl_admin_reserve_kbytes = min(free_kbytes / 32, 1UL << 13); >> + sysctl_admin_reserve_kbytes = min(free_kbytes / 32, SZ_8M); >> return 0; >> } >> subsys_initcall(init_admin_reserve); >> @@ -3898,12 +3898,12 @@ static int reserve_mem_notifier(struct notifier_block *nb, >> case MEM_ONLINE: >> /* Default max is 128MB. Leave alone if modified by operator. */ >> tmp = sysctl_user_reserve_kbytes; >> - if (0 < tmp && tmp < (1UL << 17)) >> + if (tmp > 0 && tmp < SZ_128M) >> init_user_reserve(); >> >> /* Default max is 8MB. Leave alone if modified by operator. */ >> tmp = sysctl_admin_reserve_kbytes; >> - if (0 < tmp && tmp < (1UL << 13)) >> + if (tmp > 0 && tmp < SZ_8M) > (1UL << 13) != SZ_8M > >> init_admin_reserve(); >> >> break; >> -- >> 2.25.1 >> >>
diff --git a/mm/mmap.c b/mm/mmap.c index 476de5daf598..f90924b2a6d2 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3845,7 +3845,7 @@ static int init_user_reserve(void) free_kbytes = K(global_zone_page_state(NR_FREE_PAGES)); - sysctl_user_reserve_kbytes = min(free_kbytes / 32, 1UL << 17); + sysctl_user_reserve_kbytes = min(free_kbytes / 32, SZ_128M); return 0; } subsys_initcall(init_user_reserve); @@ -3866,7 +3866,7 @@ static int init_admin_reserve(void) free_kbytes = K(global_zone_page_state(NR_FREE_PAGES)); - sysctl_admin_reserve_kbytes = min(free_kbytes / 32, 1UL << 13); + sysctl_admin_reserve_kbytes = min(free_kbytes / 32, SZ_8M); return 0; } subsys_initcall(init_admin_reserve); @@ -3898,12 +3898,12 @@ static int reserve_mem_notifier(struct notifier_block *nb, case MEM_ONLINE: /* Default max is 128MB. Leave alone if modified by operator. */ tmp = sysctl_user_reserve_kbytes; - if (0 < tmp && tmp < (1UL << 17)) + if (tmp > 0 && tmp < SZ_128M) init_user_reserve(); /* Default max is 8MB. Leave alone if modified by operator. */ tmp = sysctl_admin_reserve_kbytes; - if (0 < tmp && tmp < (1UL << 13)) + if (tmp > 0 && tmp < SZ_8M) init_admin_reserve(); break;