Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1672311ybb; Fri, 29 Mar 2019 09:01:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXU9gthew0yKfVFaU4M0tu4iOrATVzt1Ek3lL+R1/iZ/zlbiWOyOkwuqSsgreYUZMlyvqO X-Received: by 2002:a63:e151:: with SMTP id h17mr46497166pgk.413.1553875309555; Fri, 29 Mar 2019 09:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553875309; cv=none; d=google.com; s=arc-20160816; b=U1L68e7xvuKzh7qicOl/ZHJ8RMCtXiaspL4yanX0oC8OZHBNiOHtB43XkRe2bIAtPo KG2J6QvUxtnhZpEVKVl3kKZ7AwoNSbsvP8K28aII7InR5aOdFJb3yGcfy57KOoDsYeyw IpUEhp0gd4rMjYWQCYuvmnYbhTzGv5ZUuR13H91JmswT7TR4clT/1k7II0twMu5+2o1R EgFs0cw0cgT7eGkk2+omEyQ2RE28IwCOzb0XwgluExVbOhkh0kGOX0K2npObBtXD3T2s u1lViRwoQWHYoj7PJOy9tgk7bf3vwldnKqaKW7u7UM7oAOhP0+geEbYmvhXAdFmHgBpq 5R5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=4V5sQShKmoDEmjjbDrynbQSxEwhXjukz0aLZkhIYYv4=; b=w+oXWSTTuxmV8n4cX/9gl7KySexZAaIFKAFHz93vuM35ZRf5eYcwk0ezMGaBmAM88W HZ6EdrHo1C+BludJtKNSyEu6NdmvmpiMBUFQJM2xL5L2NV2Qff6vJnIUiBueHtDpbK2W kuStLi899cP1PTiKGr8h4v6jkhz4yMY5zjrva9ws9Bse18ylvHzrniKHASK4zIJ7d8I7 vxyC63H+Lvn2MMqWLTeBFo9QFXaRk+yD4L56okVZpWhJ79GIVdbKw5J9BJVpkKrXIgUk +srjAO1UU3IETWFDFmPk8flyKFUzj93rM1OTaE33hNas0gnBuy2RjjfykCDpzZFjRi9i Qm4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Xjf8FyZo; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si2072853plo.125.2019.03.29.09.01.34; Fri, 29 Mar 2019 09:01:49 -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=pass header.i=@google.com header.s=20161025 header.b=Xjf8FyZo; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729651AbfC2QAq (ORCPT + 99 others); Fri, 29 Mar 2019 12:00:46 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:36965 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728961AbfC2QAp (ORCPT ); Fri, 29 Mar 2019 12:00:45 -0400 Received: by mail-yw1-f68.google.com with SMTP id w66so848745ywd.4 for ; Fri, 29 Mar 2019 09:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4V5sQShKmoDEmjjbDrynbQSxEwhXjukz0aLZkhIYYv4=; b=Xjf8FyZoJnfK7UXhcyUKPo5VUYyrf3DnYUcJ9U4X70Yu5KAwlKJi6rPsLNlKoQ33rs f6pyWEKkSMuVDklPNlOxdZVssB1gIRQD03r7NTChqQcWnGDlT7qfeH8N0241cOGU4WLp pADXJEs74am39QIE6iXUA39pxOTEhwWUZXyxScjNFiwgY2NpexJjYbFPfQd8USWYx471 dJ2AmaH6qlepKzm3z81T2HrDO9pArk7R2TAEcLRnID0DVQe0VrCGeOfZ3iFxAjcQofqc nQIc52uk+tb/ZCLLDRpyUo378xFHEO6oOoZ7b0kW6MaBVkeR/5/+FkZnfqnL52qLl5PP iKzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4V5sQShKmoDEmjjbDrynbQSxEwhXjukz0aLZkhIYYv4=; b=TDQ5qeGY/tYz544TzZ2cgoiQtRlKEH7P8Hbma2FNk+MA239E3MQPLk3I/ovE62131v /j4jwn+Prebx5bPJL/ObhOhN796rUChEAwpxkxB55AgLwT8AjH6LkN1CSBC+/btzLM0y mK/blxmsWIjS9BUbZNfN4/l/aFFosBZYcGTHcCGCArj09zT5DDcWU2swPBM2/00IlYLq GGoxz5Hne2M2P8/6GQAdjAN7+dnUYEW30kz/SLMPI2AEMf2L1a+/drp0Dmgwh9yogD1Y yvqurivMfPn6c2TvZPJxDE4Gue67xcoqkrS042pAMQFdNdjQQJM3/6D85N4uu/SXCoAH OkpQ== X-Gm-Message-State: APjAAAVAaQxxTWW3N6vBzrMhSJpBNIlLfDo3acheX2RA/IdCZ9lPSAlN DneI8JUayoROYlPR7NXFyPfr5+ZzylOYHbsJFCWsvQ== X-Received: by 2002:a0d:e6c9:: with SMTP id p192mr7150620ywe.255.1553875244213; Fri, 29 Mar 2019 09:00:44 -0700 (PDT) MIME-Version: 1.0 References: <20190329012836.47013-1-shakeelb@google.com> <20190329075206.GA28616@dhcp22.suse.cz> In-Reply-To: <20190329075206.GA28616@dhcp22.suse.cz> From: Shakeel Butt Date: Fri, 29 Mar 2019 09:00:32 -0700 Message-ID: Subject: Re: [RFC PATCH] mm, kvm: account kvm_vcpu_mmap to kmemcg To: Michal Hocko Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , Matthew Wilcox , Paolo Bonzini , Ben Gardon , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Linux MM , kvm@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 29, 2019 at 12:52 AM Michal Hocko wrote: > > On Thu 28-03-19 18:28:36, 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. > > Is this really the case. How many machines are we talking about? Say I > have a virtual machines with 1K cpus, this will result in 12MB. Is this > significant to the overal size of the virtual machine to even care? > Think of having ~1K VMs having 100s of vcpus and the page size can be larger than 4k. This is not something happening now but we are moving in that direction. Also > > 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. > > IIRC the only purpose of PageKmemcg is to keep accounting in the legacy > memcg right. Spending a page flag for that is just no-go. PgaeKmemcg is used for both v1 and v2. > If PageKmemcg > cannot reuse mapping then we have to find a better place for it (e.g. > bottom bit in the page->memcg pointer or rethink the whole PageKmemcg. > Johannes have proposal, I will look more into those. Shakeel