From patchwork Wed Jan 31 03:19:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yajun Deng X-Patchwork-Id: 194475 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1645213dyb; Tue, 30 Jan 2024 19:20:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmqN5U9ZHvQ+3DCUz49O69Yy2A5Dal7bRgQ5FX67hQcF9vC5VVfwOAALlrnSdrYnJ6w7g7 X-Received: by 2002:a05:6214:5016:b0:685:1ece:98e5 with SMTP id jo22-20020a056214501600b006851ece98e5mr565527qvb.4.1706671212474; Tue, 30 Jan 2024 19:20:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706671212; cv=pass; d=google.com; s=arc-20160816; b=uhX8SSBbna+GKeJeNT6doPVZsd+KlROImOFSJMuYUr3Cm3Y2d6nQaCKPFKh4uzy6Nd NWGdsB9kAT0VTHboqu07AHMn/SDKj0ejllGnMWJ3Ypev5c3BxpdIhlqcAJb92RtPDhcZ qoHhOAVLWtaAfMrOk+lvx3Tv/66WRA54pLMvYG0hyrffXzscku07tk1x6Pdq5Z9nAwDp jSOZFEIUMCSPT3XxFoYHg5RvWPaltm7zntJfZGH2gg7P8FjUzvhtghbX3doWjHfPLBbN AI7ZuR+fAD2dhvzzeX/4I+2MRFAA05f5LmXJQirGdiQS+uCUUR4Fqq5xuZJqwfJWifSa 3NxQ== 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=bOLCUqhFevl+Ei9Gjm8Xhyhdj9guTueUm/iryM645Dw=; b=gUxrkgno97ANlHftZkrX3u73+d4utheN+urrG+2t5UKfsgsxO098S7Lpkp3F5clwNa gTA6b9S7Js+XC4OoNYxq9iZ7CD6SN/wTNYojisXi47R9XUU9bCEniP+Pmf9eJ//93kSQ lHTWZy2Pi/aoFf5cL8c983XWtRE1GJnxDjakSn3MGvYd2MBR+VeNoTN0Vfj1aduYexJI sbWcGBdUjxLmP1X/rVFooH3vnjdZo1qOw+XP6TiOoAcWci7hmMAaqG2Nhl1ejNbU3PzU UOVas8jFnm2gydArU8etUpatm1JJ1WRdimEz1kS6rsKKNTkc8F7KzANDWDCFBtQ2bpku i1gw==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45707-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=1; AJvYcCU5kDLSzhjtfIo3B+HyIh3LYZs8xFm7BkGJ9EJQHGqnASH/htm0OPQr7azDZWNqjnBV7yJA6bwJmoQSBUriwWO6yVge/Q== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s23-20020a05620a081700b0078394c072d0si6865409qks.573.2024.01.30.19.20.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 19:20:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45707-ouuuleilei=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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45707-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9725A1C21096 for ; Wed, 31 Jan 2024 03:20:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E204015485; Wed, 31 Jan 2024 03:19:56 +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 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789574473108431655 X-GMAIL-MSGID: 1789574473108431655 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;