Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1415654rdb; Tue, 30 Jan 2024 19:20:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOO9K3dXvuiisDorqEIsk2GCetuRxB7e75k97uJKKk/cS92+sImcfZK3pqLlwEbpPm0INU X-Received: by 2002:a05:620a:8104:b0:784:76d:d504 with SMTP id os4-20020a05620a810400b00784076dd504mr417261qkn.5.1706671202594; Tue, 30 Jan 2024 19:20:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706671202; cv=pass; d=google.com; s=arc-20160816; b=M4+Zz5PZw3iuk28FPkufU3frpusGiG/C5hLTfJ8c1JfpHBE6cd7TiR3y6l6QqAZolj B4LsYYbN1zFarhk+Gxq/ZKo53TVImu/KU9Jmd/ZF/gGMd5VJt24UcxDp7LncMMMmWEBa KppawB37+R5cFK5qUmt/IRiwhLwoqssbVfi14n42L/nE+qwL6elPyLMIcmYjZcP4Y1hs TEtUBodis4k2d1S955+HrJ+UEFYaaoHE2gFNS7rFGZqLkJ/mLeJt/U+Y9/cWgcKQ95Cl GpDmJRVf0RQi5GR4AWZZJrnzbX0rYRdHJFT3jWck2WxViHiaeQ90sm7anIOk8SOXaWeZ DJDA== 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=Zz364JoMX9h2N5yV5c7OrViie26VfXvY+e5Im09K4k4=; fh=gB6W+YJ9Zzc87JuLWKz5P2lWqico1QGD3KIr8fQDzHg=; b=FoZjZVxQ7M9BclHg7csu5wkB3W9RgcQfL2/EbQIvePlwlis8yiAPlca1zAXop/wxps ao7DMFPsKweaQfO2TPciJpKzD2EWoEWr6xkh9lv1GCL4xrfArWErLSKLjG5ZvjhNnDiP gjbJvSulw9cfUGcL2A97Xmiyr1bNiH09HlnJv39GIx8S8rXZmbYzF6XkGLTcgxwRXg9K uaioaC4crTBVol+ugxvBrovy/mfKpKCftZPxDdfsCe1aP7wFPhY1zuHRxJR3JzoNLRKB khsoM6pFWCZ/a+l+xUC8MaALwrHBSvEzEvyJXJKi/1WjqaQNVXamsDfnLfwPx5Ao74JU IQ6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fiVEZcoi; 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-45707-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45707-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=1; AJvYcCXJbWY7HD05/7cAA56rvY6cW5prNZLHyMYbqle4NjCMYxhQjGfHWlYIEXRHiUcLEcbwGizl9GjoEfHl9nB5dACeC8U1fp/zAi22yzYeTA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v14-20020a05620a0f0e00b007838dcd6c25si12617364qkl.399.2024.01.30.19.20.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 19:20:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45707-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fiVEZcoi; 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-45707-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45707-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 58EF41C24848 for ; Wed, 31 Jan 2024 03:20:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E29A11196; Wed, 31 Jan 2024 03:19:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="fiVEZcoi" Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (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 C2E551079B for ; Wed, 31 Jan 2024 03:19:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706671194; cv=none; b=Ob17OMRxbuI2Fga2QzVGYGT2IN9rycktM4/5MI0/oJYkziBSwgO+BueP//dQzi3M8alUJAHeNeQTCaYKrN/JGAzqwb0klc+wGryWH39GmB6V0esr6qHEvSEVhHnZox2UY1SuqBf0mMFrvur9JumfjEFMaDrLggEysk/WAKy5Jh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706671194; c=relaxed/simple; bh=rTqgrUM/f3lW+qEBuBNBmq/CllB8SiNYN3i5kJu39P8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=oEkci+CLdHLX131wNWPwitFVESKweUByQvqticw4lII0RkDgd8t+Nhft9wkoEA5ZU594LfXPaWJ10IRFFrLstM9gNVGrKo/c2oGFYPhX6/z4LHUknnpol5FIeX27obij3GafzuJGwTwinnXa2FnJSEcIRmwh1pVN8atvHi/zneg= 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=fiVEZcoi; arc=none smtp.client-ip=95.215.58.171 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=1706671189; 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=Zz364JoMX9h2N5yV5c7OrViie26VfXvY+e5Im09K4k4=; b=fiVEZcoirkHU005RRkF9Yqx4zJ7jWfTNJ1Gvjw9OI5phD40jJwwGqgSEIIm5PjQ3m3I3fb ML0iMug8p1/f4yXd4ctCoFgjPTnvKKnndHOY2XSVb08y826pzQDGm2UPflfgTdv+xJPet8 OCr0oQeszoukVsmtiJ3u7lE61EoFshI= From: Yajun Deng To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH v2] mm/mmap: use SZ_{8K, 128K} helper macro Date: Wed, 31 Jan 2024 11:19:13 +0800 Message-Id: <20240131031913.2058597-1-yajun.deng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Use SZ_{8K, 128K} helper macro instead of the number in init_user_reserve and reserve_mem_notifier. This is more readable. Signed-off-by: Yajun Deng --- v2: use the right helper macro. v1: https://lore.kernel.org/all/20240126085905.2835513-1-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 7000c14a039f..6722368a48dd 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3847,7 +3847,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_128K); return 0; } subsys_initcall(init_user_reserve); @@ -3868,7 +3868,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_8K); return 0; } subsys_initcall(init_admin_reserve); @@ -3900,12 +3900,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_128K) 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_8K) init_admin_reserve(); break; -- 2.25.1