Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp198314pxj; Thu, 3 Jun 2021 04:37:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSutyUF7GQTYHwKWgqHv6OMyL+P3KT9jbl3zF/plkHffV103QGQal4nk0x3Z98yQpW05Fu X-Received: by 2002:aa7:db93:: with SMTP id u19mr43819782edt.227.1622720260005; Thu, 03 Jun 2021 04:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622720259; cv=none; d=google.com; s=arc-20160816; b=FvZKWnd8Rb3njHOO6KMRJaxXBWQ2QIxGNRSUtkZeG9JVS9yDIEStgBVimQBSUpCPA1 I+f3rh/SMAYDYuf1GgXw43N+eqemnV8sCuHHEv4wuvAmY2cWzkFkscUFKHAKKHa4ZIPm nwAAsDv6dS57oVoSr9ynJxu2zMC9LJy0X6krmgqCXRLEX3mhxcgXT+HfxkU8teCDcDoS T3UDuoJpZ5cFySjk48/h+mUfVUV5okWkr1LxuLlVlESFtMuDYjJf0XVOKPgdeeeW6Hf1 dZ8Perv9cOKXJcvx3bL23dtUf2PuZ72A0yysc1Q8maDQvePNgYDogspx9Zk9kHMf6KzE oY8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=dDlsfUVoPz4mflmjcY/17kiGQZC/D+4tAfNsl24/syY=; b=TUNfnxOLMzrIwfz7YtK7L9kPWnYnOlC6otIl86NRXnAUMiUp6GNGkaDqB/L+I1u3V7 xMMYcm2TaVCe+B3GpEMMVovzSIuFYkkfm8Y77d+1w8n8JrqqxfDEiOtEUnYtO17W+8ZJ nDeDeMMEcrIuggDFjNgiosltGKpttYhu0qLNQl1kwv7oZmwDLICtp/eSm9SixnCMa49L g6lAnZhgbK+Hz5A13/gMwb1hvtY8YShOg3hzsVbyPfcaey57XrBIQ9pa5pqZyEFWvTON idFoZbA9nQnh1OquQG5TkTBpOKO+nlktrF3LM1pOl7aR0VzBWCJF/Th7QxQXf5HzIV8c Oz8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=I33Sa5Pd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz3si2077691ejb.9.2021.06.03.04.37.17; Thu, 03 Jun 2021 04:37:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=I33Sa5Pd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229926AbhFCLhA (ORCPT + 99 others); Thu, 3 Jun 2021 07:37:00 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]:53843 "EHLO mail-wm1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229840AbhFCLg7 (ORCPT ); Thu, 3 Jun 2021 07:36:59 -0400 Received: by mail-wm1-f42.google.com with SMTP id h3so3184319wmq.3 for ; Thu, 03 Jun 2021 04:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dDlsfUVoPz4mflmjcY/17kiGQZC/D+4tAfNsl24/syY=; b=I33Sa5PdYGfNQKY6cAOIwcMXmeroW1m4Oz5alOZxht7s147JhQGghyjwGeESW8gRo6 SuP7K1TW+jJxffBQf2GxFw1F6/UzK1CV4s4VSF8AE9U4cL9xDRHxoG/oa6eHYczCRMj+ ahTYmh0FeW4SmS7S7hRi1WnWRh6Ci+cqtf3UA= 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=dDlsfUVoPz4mflmjcY/17kiGQZC/D+4tAfNsl24/syY=; b=QANP4H/Arrqc+rdpPiUUhNKw1RLofWT+Tk82X+2TsOemhVoezcgLFxScnQ/DKMp5iw DXD//DTFakbwQos11VqZLFXoMFs4KTDr9FNcUuuBaa4f8qodVDswsB5T7VXHgBwi4Zki mNGDedmlbhF8mb8Xxi0rC1nZ4p2y+Tl4QXp6w7pH2O0MBW4jjF9rrorjlMcqSf3TxllZ XX7GF5h1S4xKIgjg2PMrzb27AvOuUgJP5FSN6kdLjhHd50Kf//8iA4x0MKv9+gQVN0xB p6CJuBHiphe8dIFjhE8gZOXVyGa9y1nR7UdSichlosN0ZFKi4IDEkun5U6n/h9X1uACW ZI5w== X-Gm-Message-State: AOAM533KpA9kPeiYCpRV0QOZkOt5219j7DITQlhObWMR2/3WQXPo+TwM /v7ZAVpthgtpTy630bBv1M/UyXygbUHUvrVmZsc= X-Received: by 2002:a1c:7402:: with SMTP id p2mr9615488wmc.88.1622720039043; Thu, 03 Jun 2021 04:33:59 -0700 (PDT) Received: from localhost ([2620:10d:c093:400::5:6726]) by smtp.gmail.com with ESMTPSA id l16sm5710461wmj.47.2021.06.03.04.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 04:33:58 -0700 (PDT) Date: Thu, 3 Jun 2021 12:33:58 +0100 From: Chris Down To: legion@kernel.org Cc: LKML , Linux Containers , Linux Containers , Linux FS Devel , linux-mm@kvack.org, Andrew Morton , Christian Brauner , "Eric W . Biederman" , Johannes Weiner , Michal Hocko Subject: Re: [PATCH v1] proc: Implement /proc/self/meminfo Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.7 (481f3800) (2021-05-04) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexey, legion@kernel.org writes: >From: Alexey Gladkov >The /proc/meminfo contains information regardless of the cgroups >restrictions. This file is still widely used [1]. This means that all >these programs will not work correctly inside container [2][3][4]. Some >programs try to respect the cgroups limits, but not all of them >implement support for all cgroup versions [5]. > >Correct information can be obtained from cgroups, but this requires the >cgroups to be available inside container and the correct version of >cgroups to be supported. Then they should add support for it. We already export these metrics as part of cgroups and plenty of applications like Docker, podman, containerd, systemd, runc, etc already support it. Putting stuff in /proc to get around the problem of "some other metric I need might not be exported to a container" is not a very compelling argument. If they want it, then export it to the container... Ultimately, if they're going to have to add support for a new /proc/self/meminfo file anyway, these use cases should just do it properly through the already supported APIs. >+ for_each_online_node(nid) >+ mem_cgroup_nr_pages(memcg, nid, mi->pages); >+ >+ mi->slab_reclaimable = memcg_page_state(memcg, NR_SLAB_RECLAIMABLE_B); >+ mi->slab_unreclaimable = memcg_page_state(memcg, NR_SLAB_UNRECLAIMABLE_B); >+ mi->cached = memcg_page_state(memcg, NR_FILE_PAGES); >+ mi->swapcached = memcg_page_state(memcg, NR_SWAPCACHE); >+ mi->anon_pages = memcg_page_state(memcg, NR_ANON_MAPPED); >+ mi->mapped = memcg_page_state(memcg, NR_FILE_MAPPED); >+ mi->nr_pagetable = memcg_page_state(memcg, NR_PAGETABLE); >+ mi->dirty_pages = memcg_page_state(memcg, NR_FILE_DIRTY); >+ mi->writeback_pages = memcg_page_state(memcg, NR_WRITEBACK); >+} This presents an extraordinarily confusing API. A cgroup can contain more than one process, so it's not right to present this information as "meminfo" in /proc/self when these statistics may not have any relation to the current task under question.