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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 5AACFC43464 for ; Mon, 21 Sep 2020 08:03:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A6CC520BED for ; Mon, 21 Sep 2020 08:03:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="v4QQxqar" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6CC520BED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E6913900036; Mon, 21 Sep 2020 04:03:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E18C9900029; Mon, 21 Sep 2020 04:03:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D07FF900036; Mon, 21 Sep 2020 04:03:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id B7E7D900029 for ; Mon, 21 Sep 2020 04:03:09 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 776CD3628 for ; Mon, 21 Sep 2020 08:03:09 +0000 (UTC) X-FDA: 77286328098.05.chain05_330c08e27143 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 5E82E1801DBD9 for ; Mon, 21 Sep 2020 08:03:09 +0000 (UTC) X-HE-Tag: chain05_330c08e27143 X-Filterd-Recvd-Size: 5161 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Sep 2020 08:03:08 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id q4so7023087pjh.5 for ; Mon, 21 Sep 2020 01:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MQ9zzgzZmaH7SVE72fu66K8V5NhJkHfIKNhfWRZkT70=; b=v4QQxqar9/gUAXuiOZ1QrCEiXJN++eMu4eslr0jnEjDgUQudhSX7PzLs1mguRYwEpD 6nkSdkiD7br/G4EQ6WhJUlm1untmUXqZKp7Z+IW4wA4DcjThUG6nDSGQW5GCYsOKpdM6 nyMrYP/Bmmcbm8dKzQ5Tdhf0HBdA+ZAG3QzTyMwSAttZZPkei/hd+/dqxACc4zUrAhUt 1m1tdlhySvfBll7Cm8W0n1sayUPNVPERUYYlH+phSYii1EBT3u+mmQPonDxSC23sML3t DpuBxNMDBx0DT4Bdheea6pVTfRYo0Y9XBuid0omy8AHz2W/Pi9KrumKsLcVedd9Kl484 m0Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MQ9zzgzZmaH7SVE72fu66K8V5NhJkHfIKNhfWRZkT70=; b=FbMdDD0MbyrroZ4aRfHleBKuDf44pqScOnIWu56uj0N3yqpzZSOEiHv9LcGkRVh3wl T313KzUwdkCq5iYCQUEqQuuv4jPz83wwKV+o0mnu4IkTdUkU0WWNKiPypX97FDpWfPAt 4L5dKC3w43GPYiNe05vZEla4/qQ5ig7MPRD7ZADlDyONHzIKXpWdEVwRfyEt4Kz4m/ya hM8HtkQBOZmU6rNcOzFplKYHFCAVwNemU4W538gO4cP1pSH/YpDtyKAveobUdyezPdxH Chf4QYFQKzam6FETo1sP9TgdMFozW5ulbryOFQL10lBrnhAP6lYvF4Lof0FW7lJtq9OT +daw== X-Gm-Message-State: AOAM531P0XVSpGnJ0hQZbx8PjmRUVTmBHepnXneSj0JflXGoFPH4aw1n laQw5NIv64lSbK8yNXeeD2X0ZQ== X-Google-Smtp-Source: ABdhPJykdY9XaYIuHd3HipxwMdwfsSeHmOqtcFUJirp24BFcbIXt+ifViiOUeeAn3CsKn35Wjkb3Ug== X-Received: by 2002:a17:90a:d152:: with SMTP id t18mr22628479pjw.27.1600675387607; Mon, 21 Sep 2020 01:03:07 -0700 (PDT) Received: from Zs-MacBook-Pro.local.net ([103.136.221.70]) by smtp.gmail.com with ESMTPSA id s24sm9741972pjp.53.2020.09.21.01.02.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2020 01:03:06 -0700 (PDT) From: zangchunxin@bytedance.com To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, tj@kernel.org, lizefan@huawei.com, corbet@lwn.net Cc: ast@kernel.org, daniel@iogearbox.net, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, andriin@fb.com, john.fastabend@gmail.com, kpsingh@chromium.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Chunxin Zang Subject: [PATCH] mm/memcontrol: Add the drop_cache interface for cgroup v2 Date: Mon, 21 Sep 2020 16:02:55 +0800 Message-Id: <20200921080255.15505-1-zangchunxin@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: From: Chunxin Zang In the cgroup v1, we have 'force_mepty' interface. This is very useful for userspace to actively release memory. But the cgroup v2 does not. This patch reuse cgroup v1's function, but have a new name for the interface. Because I think 'drop_cache' may be is easier to understand :) Signed-off-by: Chunxin Zang --- Documentation/admin-guide/cgroup-v2.rst | 11 +++++++++++ mm/memcontrol.c | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admi= n-guide/cgroup-v2.rst index ce3e05e41724..fbff959c8116 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1181,6 +1181,17 @@ PAGE_SIZE multiple when read back. high limit is used and monitored properly, this limit's utility is limited to providing the final safety net. =20 + memory.drop_cache + A write-only single value file which exists on non-root + cgroups. + + Provide a mechanism for users to actively trigger memory + reclaim. The cgroup will be reclaimed and as many pages + reclaimed as possible. + + It will broke low boundary. Because it tries to reclaim the + memory many times, until the memory drops to a certain level. + memory.oom.group A read-write single value file which exists on non-root cgroups. The default value is "0". diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 0b38b6ad547d..98646484efff 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6226,6 +6226,11 @@ static struct cftype memory_files[] =3D { .write =3D memory_max_write, }, { + .name =3D "drop_cache", + .flags =3D CFTYPE_NOT_ON_ROOT, + .write =3D mem_cgroup_force_empty_write, + }, + { .name =3D "events", .flags =3D CFTYPE_NOT_ON_ROOT, .file_offset =3D offsetof(struct mem_cgroup, events_file), --=20 2.11.0