From patchwork Fri May 18 04:34:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: TSUKADA Koutaro X-Patchwork-Id: 10408177 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 D969D601F9 for ; Fri, 18 May 2018 04:34:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C716D286F1 for ; Fri, 18 May 2018 04:34:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9D6728856; Fri, 18 May 2018 04:34:55 +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=ham 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 046262884F for ; Fri, 18 May 2018 04:34:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A5646B056E; Fri, 18 May 2018 00:34:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 22CDB6B056F; Fri, 18 May 2018 00:34:54 -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 0D06D6B0570; Fri, 18 May 2018 00:34:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id B926E6B056E for ; Fri, 18 May 2018 00:34:53 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id s17-v6so2390748pgq.23 for ; Thu, 17 May 2018 21:34:53 -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=L6K5x3cl50y0u/ZLa5/Ko0K/wJHUNHFa5QIahagoggk=; b=tawTKZfbPzyC9Khf70ZovwWzfImlpUP/L5JL5OsPn/j/yBLHF04IxpwHKF3CDHGANZ DZHv0uPVHmnHf9V+m3kRKErqNNt554fDodxu4oJIm0kbngcuA4qcwP6FR+PDAzwybAwC UhBFuw5wdKrM9nrytBfMM6GFp0ZYFK8IEdz+gb5XNLN0Fo4g2hK6GxQuShn+j8aY3zEk TpuHvNMZQvKy8RacRYw5t/RDKwTkU0n3YXbHXXHE8REsA0bQnfD4h4Par/mMVaqA3BOI +FzrvYPB7PwE3OewAr57Wn93l/S67kg+p3AN656cBZ+ysy7QvnqKVfsUx7Q0Q75GqiB0 jS/w== 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: ALKqPwdg0xmN45MOtpN3F8MIJ1LehdYbv576deu1MjuRaAPaGTGo5M9w m9Zs/LUyevmkFzqg8CSVjFBDTUK8bB2i1VscLOpDcoozv51p0RcJIAs3bI5oCYD+AU6jjaItFr7 /9sFkK8cvya4HHfxB0EmLEGdaAn2PWMjENhOUA3k1NO5abvLltIVXpiIBcY2E0YFCjw== X-Received: by 2002:a62:ecdc:: with SMTP id e89-v6mr7888395pfm.33.1526618093442; Thu, 17 May 2018 21:34:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr/EJufGAjILz8gspUVttw/c/t0KZyKok+J/6+tZTX/3qSh/b8GZFatouboiqJ8PLJQkMhl X-Received: by 2002:a62:ecdc:: with SMTP id e89-v6mr7888363pfm.33.1526618092729; Thu, 17 May 2018 21:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526618092; cv=none; d=google.com; s=arc-20160816; b=dybH6wOgfWCJM+KlO0q/ihojCYan9TVQRMBDHN/196Ln+iB9QZVGBTbKKgTCLuirWm Dlla8eCR+KNcDouCpWSTjkuGH4FZ/j7weoq+Q1yW1j25osBvWXc7AFZ3LKVbuQG5bDkJ L3E0BUGrURFhqJTVmYsc0S624cJ0bzSoMMJCqjnkc7RuyTqfARDh19PE1gb8p2FAcJi0 XtXmUlZux/kia6D6DXjEFvu+DycOsSdSwD35BKrHDvizJgabUp1EGVCQpncwshv+XNY3 qW/wVkRWNH2r12TuVMrFGIiAJIFrENKJRbmxr7g0jVvDBxAkXddww7YKT2Mnbxq9fCIp y64g== 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=L6K5x3cl50y0u/ZLa5/Ko0K/wJHUNHFa5QIahagoggk=; b=lKCyabC0gOCiE6HpA2ONX7Pb1vsZfpiURvgBeNVw2sDg6/JVOJ4Bxy66tjFHZrZf9c M4EatRlN4LT8Awx0Yclta+X1jMxRHOUPt+U/ILjZpeBHh5szyKFUzRIq12QFKK/3iurR HsgqOvuwxtcMK0ibyVEDnoKI0W3W9MSZfRc4TARAlXYyir6xStDs4BI5X7u+lyfdvpOQ tUk6Q9gElnt6wyrCsKHE0CZpID44qtFehP9cj5IMELV5ZMbkQ3NGmVz3Y2EeFru9ltS+ sA5nJHO6/Rn4s6VCd2D3Iak4ONKQpJ/VMxzu5hc4+NOkm5RrzfXV2Ol9KaF1fvzURAf0 nSoA== 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 r14-v6si6713415pfa.296.2018.05.17.21.34.52 for ; Thu, 17 May 2018 21:34:52 -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 BAB3C993D1; Fri, 18 May 2018 13:34:51 +0900 (JST) Received: from [IPv6:::1] (server0001.ascade.co.jp [10.1.1.63]) by server0001.ascade.co.jp (Postfix) with ESMTP id 08ED81004E1; Fri, 18 May 2018 13:34:42 +0900 (JST) Subject: [PATCH v2 3/7] memcg: use compound_order rather than hpage_nr_pages 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: <262267fe-d98c-0b25-9013-3dafb52e8679@ascade.co.jp> Date: Fri, 18 May 2018 13:34:26 +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 The current memcg implementation assumes that the compound page is THP. In order to be able to charge surplus hugepage, we use compound_order. Signed-off-by: TSUKADA Koutaro --- memcontrol.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2bd3df3..a8f1ff8 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4483,7 +4483,7 @@ static int mem_cgroup_move_account(struct page *page, struct mem_cgroup *to) { unsigned long flags; - unsigned int nr_pages = compound ? hpage_nr_pages(page) : 1; + unsigned int nr_pages = compound ? (1 << compound_order(page)) : 1; int ret; bool anon; @@ -5417,7 +5417,7 @@ int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm, bool compound) { struct mem_cgroup *memcg = NULL; - unsigned int nr_pages = compound ? hpage_nr_pages(page) : 1; + unsigned int nr_pages = compound ? (1 << compound_order(page)) : 1; int ret = 0; if (mem_cgroup_disabled()) @@ -5478,7 +5478,7 @@ int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm, void mem_cgroup_commit_charge(struct page *page, struct mem_cgroup *memcg, bool lrucare, bool compound) { - unsigned int nr_pages = compound ? hpage_nr_pages(page) : 1; + unsigned int nr_pages = compound ? (1 << compound_order(page)) : 1; VM_BUG_ON_PAGE(!page->mapping, page); VM_BUG_ON_PAGE(PageLRU(page) && !lrucare, page); @@ -5522,7 +5522,7 @@ void mem_cgroup_commit_charge(struct page *page, struct mem_cgroup *memcg, void mem_cgroup_cancel_charge(struct page *page, struct mem_cgroup *memcg, bool compound) { - unsigned int nr_pages = compound ? hpage_nr_pages(page) : 1; + unsigned int nr_pages = compound ? (1 << compound_order(page)) : 1; if (mem_cgroup_disabled()) return; @@ -5729,7 +5729,7 @@ void mem_cgroup_migrate(struct page *oldpage, struct page *newpage) /* Force-charge the new page. The old one will be freed soon */ compound = PageTransHuge(newpage); - nr_pages = compound ? hpage_nr_pages(newpage) : 1; + nr_pages = compound ? (1 << compound_order(newpage)) : 1; page_counter_charge(&memcg->memory, nr_pages); if (do_memsw_account())