Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1089416ybb; Thu, 28 Mar 2019 19:38:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBOh8MNrVA5/cvy3l8EuxkvuOZU/Pintg/YnFcJQfzcnAnYASQug+LBK3RIzdnI1z0y8/8 X-Received: by 2002:a17:902:be04:: with SMTP id r4mr32729160pls.218.1553827098089; Thu, 28 Mar 2019 19:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553827098; cv=none; d=google.com; s=arc-20160816; b=k6nwa8x+lbd3/c6ZUgetBT8oZu63Zt9cVakdv/78ZrT70j78JVDB6fpRCHdL0TsGzp boDRGluZZJnf1e0JTPUyuL+GCNhKDxEItZtLZczDgIxGcxY/bhNSnZ45rCJdbmh7fTRc cDM66typBzQt3XkRsBUZvhjjmjTRCh5AGgNPt+0oVWI0MJpFlqzh3Ecm7o5uTKmXJgdS u5x0JSf3K8Jzfr4zSXofNwAvoFGMlqrc9kippjdmxTxHQoqJBBxMxStxpcdLgzTUhKxz Pm9xnxLuzwKOJh9EKsdDTnTUiuUgAjhj0C/1V/wDmGAhHWLT763FqLHakVhAyKfJNTJe GRtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=x5wrJojQMwMMqNV4mUTxSiikQGMgZPFASdd4DPbfGYk=; b=sYSXcmf5uzmdVfvHmaEifj+Vul8IkWqtJhkkfFFGvzs3514iPs9m1euDF5lfn2f8ed bCOweqMS354PQozmd9MMrcZtm1mamyJWhcm3BCSTu7mzPWYp2j+xQHBG+kk8fuE3UMck LeYircb1gRhEJWmMm/fLxyWqIa60u1Tnm4drkEISoyUQi7npErdlRM1I3KvjbnZt7OIj 0PbpDpvzGLjucZ6ctZU4jhk0EN9xkBwo3xUnitHeAFq912pJBB4KXuKk3kFnr5CiVTXg WewLJj2gkYoREuZWcWS0Dv0tuNNAQAPr0mF0t3+5HJ37Zxm7fNH/YmgnUlhoYdeicIRD JT4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PXodbKoz; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j4si736695pgq.170.2019.03.28.19.38.02; Thu, 28 Mar 2019 19:38:18 -0700 (PDT) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PXodbKoz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728652AbfC2CgF (ORCPT + 99 others); Thu, 28 Mar 2019 22:36:05 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:34802 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727675AbfC2CgF (ORCPT ); Thu, 28 Mar 2019 22:36:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=x5wrJojQMwMMqNV4mUTxSiikQGMgZPFASdd4DPbfGYk=; b=PXodbKozTbre1PKAnjXqjKbQv xHZWToZbgAeVVsGULg9dl9/vJlMuQy1v4CVR/DM3ujbpNrs0G8UrSkbbR5vCaXOEhikUrxz4preRj 8SoYWLQTUvdfUquKH0N+DG9f0pkEb6zEmhQ1HPPwc6Dt0Y6n6Q0XzfL6lrV3wK8t8Ow4aOzPBkvyU SUzMfyObSEtBJGnh3SGZ0IQM2vOuYIDipmD0A9wb9/Y5tVrQGx5Br3Nkm/0MwSg5lxY7yBJ554lVe n9kg7bodgAEErghL+I/5CEgcAOjn+0KAKLKSv463Ui0evX4GqNxOdxpcgG32YWFMBnET2wUWTXVSI QCYlBdpMA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9hN3-0000Eh-Ii; Fri, 29 Mar 2019 02:35:53 +0000 Date: Thu, 28 Mar 2019 19:35:53 -0700 From: Matthew Wilcox To: Shakeel Butt Cc: Johannes Weiner , Vladimir Davydov , Michal Hocko , Andrew Morton , Paolo Bonzini , Ben Gardon , Radim =?utf-8?B?S3LEjW3DocWZ?= , linux-mm@kvack.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] mm, kvm: account kvm_vcpu_mmap to kmemcg Message-ID: <20190329023552.GV10344@bombadil.infradead.org> References: <20190329012836.47013-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190329012836.47013-1-shakeelb@google.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 28, 2019 at 06:28:36PM -0700, Shakeel Butt wrote: > A VCPU of a VM can allocate upto three pages which can be mmap'ed by the > user space application. At the moment this memory is not charged. On a > large machine running large number of VMs (or small number of VMs having > large number of VCPUs), this unaccounted memory can be very significant. > So, this memory should be charged to a kmemcg. However that is not > possible as these pages are mmapped to the userspace and PageKmemcg() > was designed with the assumption that such pages will never be mmapped > to the userspace. > > One way to solve this problem is by introducing an additional memcg > charging API similar to mem_cgroup_[un]charge_skmem(). However skmem > charging API usage is contained and shared and no new users are > expected but the pages which can be mmapped and should be charged to > kmemcg can and will increase. So, requiring the usage for such API will > increase the maintenance burden. The simplest solution is to remove the > assumption of no mmapping PageKmemcg() pages to user space. The usual response under these circumstances is "No, you can't have a page flag bit". I don't understand why we need a PageKmemcg anyway. We already have an entire pointer in struct page; can we not just check whether page->mem_cgroup is NULL or not?