Received: by 10.223.176.5 with SMTP id f5csp2046371wra; Wed, 31 Jan 2018 15:54:17 -0800 (PST) X-Google-Smtp-Source: AH8x227A1wZEtBDFD/8Uv2xX7GVjE7/aQysitFzCbcPu1fktg83vjbxVeCFS1upgosezn+PPr/c4 X-Received: by 2002:a17:902:a589:: with SMTP id az9-v6mr9586709plb.298.1517442857464; Wed, 31 Jan 2018 15:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517442857; cv=none; d=google.com; s=arc-20160816; b=oMNZywa6R29BhFPptmWd5rlMbA3RqOKnmhoRn8N0Q5MLJOri+9VE61r3Vos6fYmlGa G8WDupkoGRIFUfyCVgfbT8FZ78LW5fw3tkDfkccTceygHOExIT9e+LicUirWGwmoToYP XuA6v8eBtmKcKTIIn1tyGeRc2KlTMlh6Apz6YF6Lv6jkV+RL3DA9Lcu/anBvwG/BDXZb Sg6CcKN8xqnbyPVjmTQ5slbDzoJb1xouQAFqKOeQgGMoHmB0lMyXX66tA9f/JMDC9JlP ATB7nx0cYjxuUsRO71baRfetWLpqkLnCfpLM2uRGHI2WLWdIRKBV3PWAQEF0ekt2FulW t7Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=au5DjnBjQWrCTkr/j8yxM2/N3oI3VH47Sln7Wp8btCY=; b=EYtfg/QPTJAXUmksyZXFsqi6KeLy7w9rgQUtO+6uWu4LPngHvzRICFszfDFi9Y+xTy eE1gSPEp4JvoIsPZgRQJxxvQ0VG/ZVEqwcMgYU/gLYAotze/YiPBpsTHzgeAiZKfIuMh jLDtZFXGvkcZf5yP1vqlPL3QcEoNfPJFIxTKBJsLfGP1x5OWIZ4/tXbGuOG2jk/cEgva 3tGA5OKp4Q/IlTT6MWJDAw7GeHPN9EU7y5n7qsrmGzC0VFK+m3QjkFnUGYh5cssmhipk NvXTFqWZwKIDXTE8mwIVCUuD/yaQYxGM16mIpP9+69k/UyedAQZeQVKr0v1HSmw/cB3w sSAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=qauCWKhW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i64-v6si375626pli.142.2018.01.31.15.54.02; Wed, 31 Jan 2018 15:54:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=qauCWKhW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755961AbeAaXPd (ORCPT + 99 others); Wed, 31 Jan 2018 18:15:33 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:44944 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754068AbeAaXEe (ORCPT ); Wed, 31 Jan 2018 18:04:34 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0VMq4BG145493; Wed, 31 Jan 2018 23:04:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=au5DjnBjQWrCTkr/j8yxM2/N3oI3VH47Sln7Wp8btCY=; b=qauCWKhWiqRXUvzNNVKJE+sfMigUCH3nkbWcjtZs4qgOwV5f9yTk6cXNAk7MnafVP5L/ QqibSUgGSHHL/up10V0LBfZlnD+Jqtgs3Qn9jhYvWxaHusJbIuEtMNtltBbQrs53C6mR yvBo/8LuyIxTtU/PJ1nO1hEqjiVXctzcNPnob5IgQQ+zQqMNHpJCcZSL0it/GKDYlgsP NmhTRupmpxib2PJ8pkYNESbiXHaqzjORS81KkhURUNziyum3KhC5Nq3WTRzWlq8MsuJr ZinwZzZusfzLFAmQF41OOK3t5xSgLF8f+YFCTdcE1w2PwH0yMLNscBqkp02uua8ja8md ng== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2fujpm98t2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Jan 2018 23:04:24 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w0VN4Nmb021533 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Jan 2018 23:04:23 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w0VN4LlM032257; Wed, 31 Jan 2018 23:04:21 GMT Received: from parnassus.us.oracle.com (/10.39.213.30) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 31 Jan 2018 15:04:21 -0800 From: daniel.m.jordan@oracle.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: aaron.lu@intel.com, ak@linux.intel.com, akpm@linux-foundation.org, Dave.Dice@oracle.com, dave@stgolabs.net, khandual@linux.vnet.ibm.com, ldufour@linux.vnet.ibm.com, mgorman@suse.de, mhocko@kernel.org, pasha.tatashin@oracle.com, steven.sistare@oracle.com, yossi.lev@oracle.com Subject: [RFC PATCH v1 01/13] mm: add a percpu_pagelist_batch sysctl interface Date: Wed, 31 Jan 2018 18:04:01 -0500 Message-Id: <20180131230413.27653-2-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180131230413.27653-1-daniel.m.jordan@oracle.com> References: <20180131230413.27653-1-daniel.m.jordan@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8791 signatures=668659 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801310283 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aaron Lu --- include/linux/mmzone.h | 2 ++ kernel/sysctl.c | 9 +++++++++ mm/page_alloc.c | 40 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 67f2e3c38939..c05529473b80 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -891,6 +891,8 @@ int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); +int percpu_pagelist_batch_sysctl_handler(struct ctl_table *, int, + void __user *, size_t *, loff_t *); int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); int sysctl_min_slab_ratio_sysctl_handler(struct ctl_table *, int, diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 557d46728577..1602bc14bf0d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -108,6 +108,7 @@ extern unsigned int core_pipe_limit; extern int pid_max; extern int pid_max_min, pid_max_max; extern int percpu_pagelist_fraction; +extern int percpu_pagelist_batch; extern int latencytop_enabled; extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max; #ifndef CONFIG_MMU @@ -1458,6 +1459,14 @@ static struct ctl_table vm_table[] = { .proc_handler = percpu_pagelist_fraction_sysctl_handler, .extra1 = &zero, }, + { + .procname = "percpu_pagelist_batch", + .data = &percpu_pagelist_batch, + .maxlen = sizeof(percpu_pagelist_batch), + .mode = 0644, + .proc_handler = percpu_pagelist_batch_sysctl_handler, + .extra1 = &zero, + }, #ifdef CONFIG_MMU { .procname = "max_map_count", diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 76c9688b6a0a..d7078ed68b01 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -130,6 +130,7 @@ unsigned long totalreserve_pages __read_mostly; unsigned long totalcma_pages __read_mostly; int percpu_pagelist_fraction; +int percpu_pagelist_batch; gfp_t gfp_allowed_mask __read_mostly = GFP_BOOT_MASK; /* @@ -5544,7 +5545,8 @@ static void pageset_set_high_and_batch(struct zone *zone, (zone->managed_pages / percpu_pagelist_fraction)); else - pageset_set_batch(pcp, zone_batchsize(zone)); + pageset_set_batch(pcp, percpu_pagelist_batch ? + percpu_pagelist_batch : zone_batchsize(zone)); } static void __meminit zone_pageset_init(struct zone *zone, int cpu) @@ -7266,6 +7268,42 @@ int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *table, int write, return ret; } +int percpu_pagelist_batch_sysctl_handler(struct ctl_table *table, int write, + void __user *buffer, size_t *length, loff_t *ppos) +{ + struct zone *zone; + int old_percpu_pagelist_batch; + int ret; + + mutex_lock(&pcp_batch_high_lock); + old_percpu_pagelist_batch = percpu_pagelist_batch; + + ret = proc_dointvec_minmax(table, write, buffer, length, ppos); + if (!write || ret < 0) + goto out; + + /* Sanity checking to avoid pcp imbalance */ + if (percpu_pagelist_batch <= 0) { + ret = -EINVAL; + goto out; + } + + /* No change? */ + if (percpu_pagelist_batch == old_percpu_pagelist_batch) + goto out; + + for_each_populated_zone(zone) { + unsigned int cpu; + + for_each_possible_cpu(cpu) + pageset_set_high_and_batch(zone, + per_cpu_ptr(zone->pageset, cpu)); + } +out: + mutex_unlock(&pcp_batch_high_lock); + return ret; +} + #ifdef CONFIG_NUMA int hashdist = HASHDIST_DEFAULT; -- 2.16.1