From patchwork Fri May 18 04:36:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: TSUKADA Koutaro X-Patchwork-Id: 10408211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 33CE6601F9 for ; Fri, 18 May 2018 04:49:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 215CD2866B for ; Fri, 18 May 2018 04:49:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10854287AA; Fri, 18 May 2018 04:49:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6317F28733 for ; Fri, 18 May 2018 04:49:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A2326B057A; Fri, 18 May 2018 00:49:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 750C66B057B; Fri, 18 May 2018 00:49:52 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 641236B057C; Fri, 18 May 2018 00:49:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id 204D26B057A for ; Fri, 18 May 2018 00:49:52 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id t11-v6so2447371pgn.9 for ; Thu, 17 May 2018 21:49:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:to:cc :references:from:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=e465g3YB+6FER8pij9nt2zRXo1wPcEn7ifkas1zWfJ4=; b=jYHE+c8qz/8QQqQ9FHxgBnMY100NqZMytFAWRD/4P420bOWKWs/5iOmZHazfsDy2Nh vUEnl4RupLVL5UzTd65UuXKChXXySMu52MLq/drAQIf3F1ZS67J0ZmOczr7XIXhz20ZE qXm2SeghHYf9HNdcwe9if3reRtIXQf8GT9idflCt5xoY9JACCeMIFAJuO3Uuw1bHtfub lc5+FY/+BWY9aHkbx2KsS1xBSs9q6T2ebo/yOkPjQGn0i4mT35yj29fq+xcx5Eg8TOWw lbtgQNDSbab6gmxF4JuMr7uJcVhJoG1UKr+4HoBvCNblSisn6Sm1/HaTrc+SKGprKgnG HXVA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tsukada@ascade.co.jp designates 218.224.228.194 as permitted sender) smtp.mailfrom=tsukada@ascade.co.jp X-Gm-Message-State: ALKqPwdbi3gYnbZRJpRA0wQZdQYK8jd1Um7MMPUwyK6E91UDwZVYrbNA /1/dSl9IBUkosH3jZowS6x0zuhnep4mbnYOUntaY+8tBl6wUjXpSFKB6DLoTW1TjyUCepWjQWi1 BD61H6OA4PLto6s7zfVzeE+YNLwyAJlm7qkcg1DJcWdycBCyk2VtbNObfkud51dUnzA== X-Received: by 2002:a17:902:24b:: with SMTP id 69-v6mr8097227plc.54.1526618991798; Thu, 17 May 2018 21:49:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpJWX02akIgn18p4xTItoImCQtws7Q/mVn0oQ1PfkEQcrVTX+74tmQRJs3iUw9hbpwGeugq X-Received: by 2002:a17:902:24b:: with SMTP id 69-v6mr8075430plc.54.1526618200320; Thu, 17 May 2018 21:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526618179; cv=none; d=google.com; s=arc-20160816; b=yWzId8kElsVAmjn0/0tYGkzUsaCoLS9j7MCD4tjw3mzwWCWQTUV7o4+ih+IVWzVHwP IPqAcqZVQP7fcFim9V/VYKHHBFhMP8gI3zIa4aZoO5Llphp2EuvynYQn95OPFIRu9lDP /FgKr77eCS8K5outx54VoFic2+fgu3EGZjb9Lke8RXu4W5Aj71Pvqe9s6I+TmUQGAXsT MUJGaWMDmFroKHE39nCevppU+fgWTukfbTjsUqAvspdG/TtHcVxRQdJDTYid6S3uZcwH ASxQ91DBKwtOHz/m4Drmsn44+HEHPf0nFaOB/6ON+fa2AL2jgUq11B5/gQ0U8SeIe1cH JS0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :arc-authentication-results; bh=e465g3YB+6FER8pij9nt2zRXo1wPcEn7ifkas1zWfJ4=; b=DlFlTNZJ60ZfvP5gvCaD8eClLeBwebvgEpQv93sWIL/KhiEx7mob/RuQQKrAkyjJSk o93tvXUZ0TN764KoKhULgpHnefQ7hF4CnDjUR6Fdrdhm2d9cHOS+845TE+p45xPxMrtM Gd48F2WbuK6cr4UhXve4c5uGEJUU9JjMw3O9+nOaaTCMExx/8EEelA3ItomEkSkf72Bc 9sFZns5IrJey/oFH8/8hyLQUyCzgDS7AUxxA8EDE0VuFtZzhJ5sIBd+2j0gXtMqrecp8 KTeudslJkPQPjLqwn2c6CSwNqn0dLKco9ETCAtq1pKRdk2UuogtDfG1EDViak2/mhNtC B+TQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of tsukada@ascade.co.jp designates 218.224.228.194 as permitted sender) smtp.mailfrom=tsukada@ascade.co.jp Received: from ns.ascade.co.jp (ext-host0001.ascade.co.jp. [218.224.228.194]) by mx.google.com with ESMTP id j20-v6si6475901pll.223.2018.05.17.21.36.19 for ; Thu, 17 May 2018 21:36:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of tsukada@ascade.co.jp designates 218.224.228.194 as permitted sender) client-ip=218.224.228.194; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of tsukada@ascade.co.jp designates 218.224.228.194 as permitted sender) smtp.mailfrom=tsukada@ascade.co.jp Received: from server0001.ascade.co.jp (server0001.ascade.co.jp [10.1.1.63]) by ns.ascade.co.jp (Postfix) with ESMTP id 7FAA3993D1; Fri, 18 May 2018 13:36:18 +0900 (JST) Received: from [IPv6:::1] (server0001.ascade.co.jp [10.1.1.63]) by server0001.ascade.co.jp (Postfix) with ESMTP id 159C710050E; Fri, 18 May 2018 13:36:17 +0900 (JST) Subject: [PATCH v2 4/7] mm, sysctl: make charging surplus hugepages controllable To: Johannes Weiner , Michal Hocko , Vladimir Davydov , Jonathan Corbet , "Luis R. Rodriguez" , Kees Cook Cc: Andrew Morton , Roman Gushchin , David Rientjes , Mike Kravetz , "Aneesh Kumar K.V" , Naoya Horiguchi , Anshuman Khandual , Marc-Andre Lureau , Punit Agrawal , Dan Williams , Vlastimil Babka , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, tsukada@ascade.co.jp References: From: TSUKADA Koutaro Message-ID: Date: Fri, 18 May 2018 13:36:11 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Make the default hugetlb surplus hugepage controlable by /proc/sys/vm/charge_surplus_hugepages. Signed-off-by: TSUKADA Koutaro --- include/linux/hugetlb.h | 2 ++ kernel/sysctl.c | 7 +++++++ mm/hugetlb.c | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+) -- Tsukada diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 33fe5be..9314b07 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -80,6 +80,8 @@ struct hugepage_subpool *hugepage_new_subpool(struct hstate *h, long max_hpages, void reset_vma_resv_huge_pages(struct vm_area_struct *vma); int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); int hugetlb_overcommit_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); +int hugetlb_charge_surplus_handler(struct ctl_table *, int, void __user *, + size_t *, loff_t *); int hugetlb_treat_movable_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); #ifdef CONFIG_NUMA diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 6a78cf7..d562d64 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1394,6 +1394,13 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write, .mode = 0644, .proc_handler = hugetlb_overcommit_handler, }, + { + .procname = "charge_surplus_hugepages", + .data = NULL, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = hugetlb_charge_surplus_handler, + }, #endif { .procname = "lowmem_reserve_ratio", diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 2e7b543..9a9549c 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3069,6 +3069,27 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write, return ret; } +int hugetlb_charge_surplus_handler(struct ctl_table *table, int write, + void __user *buffer, size_t *length, loff_t *ppos) +{ + struct hstate *h = &default_hstate; + int tmp, ret; + + if (!hugepages_supported()) + return -EOPNOTSUPP; + + tmp = h->charge_surplus_huge_pages ? 1 : 0; + table->data = &tmp; + table->maxlen = sizeof(int); + ret = proc_dointvec_minmax(table, write, buffer, length, ppos); + if (ret) + goto out; + + if (write) + h->charge_surplus_huge_pages = tmp ? true : false; +out: + return ret; +} #endif /* CONFIG_SYSCTL */ void hugetlb_report_meminfo(struct seq_file *m)