Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp311386ybi; Sat, 15 Jun 2019 01:29:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqykHDLQITZw9vYO5RNzCuhbY1BpXJqmGLEU9HArkJ2petqdcr8c4Z2SooVv6vReLbFEdeHt X-Received: by 2002:a17:902:9b94:: with SMTP id y20mr82291778plp.260.1560587390571; Sat, 15 Jun 2019 01:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560587390; cv=none; d=google.com; s=arc-20160816; b=l7dxxFomj7BuoP92tlLkkDdnm+XXZqb3M9vuXLwG97/WloNro4Oi/vnvecsOGzH7xz QbLPbqxTXITAOxpszzxWsD/cLPYhZJhBg7TGg53cfAeTHFkRnWlEsuPcldzDWU+z2mis ikpBZFLwKi5IATW2CPb0MmTh3k7pMlgFotytixlfLIMV4Ftax6eDexMS8rLSZzHfU29D /d5PR6n81dOx/Apfpyady2W9RJ0Bt971OZ6colyVYdBKEGW088P6ekIkbVeb4Q90BQ7O wP80zFeYLBFrIoafj68alqOLmCl8pWqzu8pymlopZvH14wLDTeUztH2S0OqNvnhPFen+ GZSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:date:cc:to:from:subject:message-id:dkim-signature; bh=bqks99JML0mByy8FjY6xU4G7QtZG+ZkGbWODY0s995M=; b=Zmzv6XEmkNNXSmJO2OGv7yM1otcROxwf49rDwBw6wZ1ZoiktsArtmBLM2JqgIBEqj4 T+ZJ2xS1w0bOVHUPugrQgVqkbL+1Re5y3CVGu9V1d7Z69OTb2LMbZCA+g8EUexxuo72u YNHhA8kA9yEeqgAuNwmcn0FhpwX55w0dBOmZd1UKkN1NqrXJNHjejnta/uPsdav9dARz 1gFiE+iMaN1D/4f3/OCEnfWcCZcOAE3GA/k8jQlmINVv07v0qbuZfgcus+YE8xzb7YCj fOMs5GhKHlEV3m/aZU2GQ98e9IvgDu/ngWZxQGlh+acSxYDdbBcXv162zZOw1h/TjCXW x8RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mengyan1223.wang header.s=mail header.b=X6WUvQ6A; 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=NONE sp=NONE dis=NONE) header.from=mengyan1223.wang Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u15si4712535pfl.76.2019.06.15.01.29.35; Sat, 15 Jun 2019 01:29:50 -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=@mengyan1223.wang header.s=mail header.b=X6WUvQ6A; 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=NONE sp=NONE dis=NONE) header.from=mengyan1223.wang Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726405AbfFOI3a (ORCPT + 99 others); Sat, 15 Jun 2019 04:29:30 -0400 Received: from mengyan1223.wang ([89.208.246.23]:56688 "EHLO mengyan1223.wang" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbfFOI3a (ORCPT ); Sat, 15 Jun 2019 04:29:30 -0400 X-Greylist: delayed 554 seconds by postgrey-1.27 at vger.kernel.org; Sat, 15 Jun 2019 04:29:30 EDT Received: from [IPv6:2408:8270:a51:2470:fdc9:19d4:d061:dd4f] (unknown [IPv6:2408:8270:a51:2470:fdc9:19d4:d061:dd4f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: xry111@mengyan1223.wang) by mengyan1223.wang (Postfix) with ESMTPSA id C3F06665D2; Sat, 15 Jun 2019 04:20:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mengyan1223.wang; s=mail; t=1560586815; bh=bqks99JML0mByy8FjY6xU4G7QtZG+ZkGbWODY0s995M=; h=Subject:From:To:Cc:Date:From; b=X6WUvQ6Am7IOROADt2MULQT0N6H5XyrHdIjWhdgp66wkT9D8yJ03fRRJg/E8IzSug gP0aGKnrhRYQxaiRYYbPD+FNjl+mcGY+DcnnpYHZJat/mcn3+jv+6UuxSAFkQC/7Fm J6Yf0nJeFn/Rq0SXJrgMZDo0dMHERBp4NR1yps8ewLikCwHpT1K9ZW7KAC5AHOJDxE MmIP//2o1N12q/4eljFk+jD8otsc+oigSiisbEjPqxj+3G/Utn+HpXRQLdbZvtl5zs EYW60BWEROdja3ZcdxvD1EgO9YE768kPQwCJJCK/G5PEiAsYo1EaNILfCRAvT7uhUf eHr2f/ibTrg5A== Message-ID: <0f1be041f8de95603753ffe989bd25069efa13bb.camel@mengyan1223.wang> Subject: [PATCH RFC] mm: memcontrol: add cgroup v2 interface to read memory watermark From: Xi Ruoyao To: Johannes Weiner , Michal Hocko , Vladimir Davydov Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Sat, 15 Jun 2019 16:20:04 +0800 Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce a control file memory.watermark showing the watermark consumption of the cgroup and its descendants, in bytes. Signed-off-by: Xi Ruoyao --- mm/memcontrol.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ba9138a4a1de..b1d968f2adcd 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5495,6 +5495,13 @@ static u64 memory_current_read(struct cgroup_subsys_state *css, return (u64)page_counter_read(&memcg->memory) * PAGE_SIZE; } +static u64 memory_watermark_read(struct cgroup_subsys_state *css, + struct cftype *cft) +{ + struct mem_cgroup *memcg = mem_cgroup_from_css(css); + return (u64)memcg->memory.watermark * PAGE_SIZE; +} + static int memory_min_show(struct seq_file *m, void *v) { return seq_puts_memcg_tunable(m, @@ -5771,6 +5778,11 @@ static struct cftype memory_files[] = { .flags = CFTYPE_NOT_ON_ROOT, .read_u64 = memory_current_read, }, + { + .name = "watermark", + .flags = CFTYPE_NOT_ON_ROOT, + .read_u64 = memory_watermark_read, + }, { .name = "min", .flags = CFTYPE_NOT_ON_ROOT, -- Xi Ruoyao School of Aerospace Science and Technology, Xidian University