From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E942C55186 for ; Fri, 24 Apr 2020 00:31:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A48421744 for ; Fri, 24 Apr 2020 00:31:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YFPVrqX/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A48421744 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DB25A8E0009; Thu, 23 Apr 2020 20:30:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D895E8E0003; Thu, 23 Apr 2020 20:30:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9F008E0009; Thu, 23 Apr 2020 20:30:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0031.hostedemail.com [216.40.44.31]) by kanga.kvack.org (Postfix) with ESMTP id B204D8E0003 for ; Thu, 23 Apr 2020 20:30:59 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 73F49180AD81F for ; Fri, 24 Apr 2020 00:30:59 +0000 (UTC) X-FDA: 76740868638.23.land98_25b40e8ae9a4a X-HE-Tag: land98_25b40e8ae9a4a X-Filterd-Recvd-Size: 4841 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Apr 2020 00:30:58 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id t4so3076095plq.12 for ; Thu, 23 Apr 2020 17:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=L5XArOSUZwIEnxR3eCf7lGVK2eb+Bi3jkepM1WeX9QE=; b=YFPVrqX/oo9QxWP7xGzlaGJ9raYM+zVB0puskfyk362PScv39Lh67FW0q+PCC8NpeG pbW8NfRzGNkrdsK4jdMh/G1k2wT9sziF6YTxoVNJ/wmwmKVvOXPga05yfPr+cbBNtnDI QNRMbCkJyu5bU0tF+Gz2dR6hbULu4Z4ktTjvQUesjqAcBKSiBdYQGFv7OX83/2QS2vP6 70MjjYA9OMDctxic2eG+QCQV3QVT8WcivhAvczc5+vH6amZtwibpZCabA//sCP+ITktv UJ6LOoeKeYB83s85iZxIxbmwLrOySFnUeMghkxwak+uK1NHrs8JDMAl9sHfTNN/+x9cj HC4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=L5XArOSUZwIEnxR3eCf7lGVK2eb+Bi3jkepM1WeX9QE=; b=kLKnZa6sqHQn/gPUCouIBdiWrL5PVH1RBGWgKjR5uh5N9TBrxLQ7lE94UbCkTtWmrL KeoflFlJNshnVO/uDZ81uKZ8daJuGsn6e+obYmBnbDutdgaPAyTnK6zW+9nqKoej0dZB XQodGj7Ex1j4pNXk5KvHAtv5CPHk9BUJwD5bhan5tZHoP0r7WKenFguiAL31DkyeO3Dp Jgyy9UXZ7oqzQSeSj1YMMtJO6oDdfllgFDrrHBH49bQJXt4+xCuveQear6BbM0in5+hB MPcuoxG8Ibqp+a1bAqUTlQvnUmEfaJPmeYqB1WNCR+AABD3N07oUXxDrwahPT9wl/3iA ja9w== X-Gm-Message-State: AGi0PuYX3sLLU7+Yvu0wzcj1fPDLBEkWhdLbmyFTbjnX5eZUhdAwzvVe POO5PJeMahFE0vH5QVEDv/A= X-Google-Smtp-Source: APiQypI3JWqoZTZWFf/ZQssaQxK4U5EkPUiDF5YTIb5ST9FWlo/Kw86wh7/VtzgytUMI/y6cnR53Eg== X-Received: by 2002:a17:902:768b:: with SMTP id m11mr2702867pll.82.1587688258138; Thu, 23 Apr 2020 17:30:58 -0700 (PDT) Received: from js1304-desktop ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id j26sm3816474pfr.215.2020.04.23.17.30.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 17:30:57 -0700 (PDT) Date: Fri, 24 Apr 2020 09:30:52 +0900 From: Joonsoo Kim To: Johannes Weiner Cc: Alex Shi , Shakeel Butt , Hugh Dickins , Michal Hocko , "Kirill A. Shutemov" , Roman Gushchin , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 15/18] mm: memcontrol: make swap tracking an integral part of memory control Message-ID: <20200424003051.GE13929@js1304-desktop> References: <20200420221126.341272-1-hannes@cmpxchg.org> <20200420221126.341272-16-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200420221126.341272-16-hannes@cmpxchg.org> User-Agent: Mutt/1.5.24 (2015-08-30) 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: On Mon, Apr 20, 2020 at 06:11:23PM -0400, Johannes Weiner wrote: > Without swap page tracking, users that are otherwise memory controlled > can easily escape their containment and allocate significant amounts > of memory that they're not being charged for. That's because swap does > readahead, but without the cgroup records of who owned the page at > swapout, readahead pages don't get charged until somebody actually > faults them into their page table and we can identify an owner task. > This can be maliciously exploited with MADV_WILLNEED, which triggers > arbitrary readahead allocations without charging the pages. > > Make swap swap page tracking an integral part of memcg and remove the > Kconfig options. In the first place, it was only made configurable to > allow users to save some memory. But the overhead of tracking cgroup > ownership per swap page is minimal - 2 byte per page, or 512k per 1G > of swap, or 0.04%. Saving that at the expense of broken containment > semantics is not something we should present as a coequal option. > > The swapaccount=0 boot option will continue to exist, and it will > eliminate the page_counter overhead and hide the swap control files, > but it won't disable swap slot ownership tracking. > > This patch makes sure we always have the cgroup records at swapin > time; the next patch will fix the actual bug by charging readahead > swap pages at swapin time rather than at fault time. > > Signed-off-by: Johannes Weiner Reviewed-by: Joonsoo Kim