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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9A09C6FD1D for ; Wed, 15 Mar 2023 02:34:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AAE26B0072; Tue, 14 Mar 2023 22:34:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 15ADF6B0074; Tue, 14 Mar 2023 22:34:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 022606B0075; Tue, 14 Mar 2023 22:34:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E734C6B0072 for ; Tue, 14 Mar 2023 22:34:37 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B01011A0D83 for ; Wed, 15 Mar 2023 02:34:37 +0000 (UTC) X-FDA: 80569564194.16.4B9B627 Received: from out-62.mta1.migadu.com (out-62.mta1.migadu.com [95.215.58.62]) by imf07.hostedemail.com (Postfix) with ESMTP id C0C4540006 for ; Wed, 15 Mar 2023 02:34:34 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mlqh3Uuo; spf=pass (imf07.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.62 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678847675; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LbW+Qz+GPh9oxvtGy6lpbTi92iahxf+9WiV70Tu5/B0=; b=xeDRWtMWI7GjmulLP5NoLNW7LNIF6OFZElR8S48YRkpocq6OcodHfv+Pu2DSDeSQhx2ydp ZiWWXgm72pxVv6di0AIKKL89D9K+Iw1x5QELKmzYjJ6n+qWWd9tOpgvZf34rfdpqHHOW17 osSeKw3DlXorDkNw5W4/ad57D95Kl9Q= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mlqh3Uuo; spf=pass (imf07.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.62 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678847675; a=rsa-sha256; cv=none; b=cIyIr8Z7jbYhdnL+2nr/ho50BwUjJ+969HxDQIb5ns04uO8oX1K/jBa4+/JDG2ue5ihTZ5 f5oYCcK/lHlefOvwackQLM3XQGWf/ez6vRcd410cFLBspzS8FTeS6lg26P3Z95okISjDUM /iW/drWk3Dw2xGRV1dOkrVUoN+A7bAw= Date: Tue, 14 Mar 2023 19:34:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1678847672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LbW+Qz+GPh9oxvtGy6lpbTi92iahxf+9WiV70Tu5/B0=; b=mlqh3Uuo8+My+UJvFW5MVIQ+o4rKsT/5XvjwyVBnNc7AZrlYyFKlYPC4kQkZdHK9ttm8jI 8rhoyXtVySZHzFZyM+M2mrbe8ntBQyyPqi+a4zAp8xdh1mfrRiOc4KslUEWdv/p9q5O3Um 8dCno8bYbK4DK7KisNitjXdeCH/L8qU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Yosry Ahmed Cc: Andrew Morton , Hugh Dickins , Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , Naoya Horiguchi , Miaohe Lin , Vladimir Davydov , linux-mm@kvack.org, cgroups@vger.kernel.org Subject: Re: [PATCH] memcg: page_cgroup_ino() get memcg from compound_head(page) Message-ID: References: <20230313083452.1319968-1-yosryahmed@google.com> <20230313124431.fe901d79bc8c7dc96582539c@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C0C4540006 X-Stat-Signature: mrsjw56tfn89i48na4ef17ice54qoija X-HE-Tag: 1678847674-37443 X-HE-Meta: U2FsdGVkX18Vnz5BwNOEs+stPDEFkraYMvC2m96LryXnCHSc+XY5nQjHIo0012chw8BydYlKytDGDovvdx7cXpS72ooeFKk5W1As90L4HKvYUNcB+ykNce6L77ptEfAmsL5bumxUs/6xalYODuH0Fc/M2n28axQrLlxSCVEpCAzpb5FEXERLssUUIPI6ecLU+AMoyzXDzkhUjQrZ7U7xLpPnzBVKRmEWlQ+jzIRUoDGwjo+AfZa5+m3tKRfy60eGZAEvn+Ip8uaadBWe6+Z8GjG9zKigqI1lNHrCDwlGoIyKks+p1IJtyprLdmTQKvb+rGLp62Hqw12YLH85T8vl0Z+zWSaz840ZRqqPaFJgzODxFxITZ/h7OcFZHEgd7r7ald5U0uzkz/wVD3pJ1ZqReloSO1OYFY8yQ4CTROv9wRwbERONQSFT6FZEX8dcJwcpTStbkDcNRK0/Fb5LsHLv0/VLjFXkLM3wuAaewFViVyKFEZzo2cnWEd/r0GyJhBvupeL8yCc0bL6GozbnXeREklib6gzWbzmw/P/Iq5RRcu56gL3Y6DAGgCDIADC1+O2IiL7/gknzKRsfr0StZDHBfTmxzh7jMl2+jWuvmCa/4jJshdM1bGMHQVhT9kJsy+1wk0jpnS0QCU1JS6IYAoOy/tw9mVLZl4+C+ZwBe5MIHXmJLqoyaZkzi80Bb7fBYj6gDm6bCOJKQCXowsrVBWqWtedawvMa8Snhzmc+tSNJFxp7iupv7RG3mgEuGNZ61AnFcr4np+7xPOC3kihvQaWQC14Yd2fZbPP8EkQUMskR4UniwhiaNrURBeiZ1DMx2a8sqmx6/mcYEThLowDWWgAdkDMtVooj9Hd0DqVR3IY9BJpQmUiV8mmthxh4ourzknQ/PVo2dF7nV0qqhLIBcETOtXK0SEjKRMW8d66nc/yqqr/hItJx6u2R8RRP6lG3YltZumnptuH9KV3O+CMVmko fldZYe6V b/kLoY/BtdGuphfRvfJ7IvY79EgNdRmpz/B0022EKWJ9vOrR+HlTO+6uUx6QiCEwKeCVUbdiaK3xGdFI9pJ5uifj2w37HOp6jYlyEq3djd0DVBHHPZu4wYvPkNQ5NeiAsapDYsPGXhQZV9Jbbjy/aoCXMO0R8oc2r7l1BcN34a+0lNq8uNbm/Px9chFDJnaBIJkSsdOn783od9AFx27FR5s/LqP0eS43841sDgDldHg3X679uxbnl8g/BHCEsGTXbyTkEFaGVkgvKyyhdqWd0IEVmp3CGHzHdYp55i0Mc7cgRXXc/z1MtMvH+qQ== 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: On Mon, Mar 13, 2023 at 02:08:53PM -0700, Yosry Ahmed wrote: > On Mon, Mar 13, 2023 at 12:44 PM Andrew Morton > wrote: > > > > On Mon, 13 Mar 2023 08:34:52 +0000 Yosry Ahmed wrote: > > > > > From: Hugh Dickins > > > > > > In a kernel with added WARN_ON_ONCE(PageTail) in page_memcg_check(), we > > > observed a warning from page_cgroup_ino() when reading > > > /proc/kpagecgroup. > > > > If this is the only known situation in which page_memcg_check() is > > passed a tail page, why does page_memcg_check() have > > > > if (PageTail(page)) > > return NULL; > > > > ? Can we remove this to simplify, streamline and clarify? > > I guess it's a safety check so that we don't end up trying to cast a > tail page to a folio. My opinion is to go one step further and change > page_memcg_check() to do return the memcg of the head page, i.e: > > static inline struct mem_cgroup *page_memcg_check(struct page *page) > { > return folio_memcg_check(page_folio(page)); > } > > This makes it consistent with page_memcg(), and makes sure future > users are getting the "correct" memcg for whatever page they pass in. > I am interested to hear other folks' opinions here. > > The only other user today is print_page_owner_memcg(). I am not sure > if it's doing the right thing by explicitly reading page->memcg_data, > but it is already excluding pages that have page->memcg_data == 0, > which should be the case for tail pages. Yeah, I think it's a good idea. I'd do this. If you'll master a patch like this, please, apply my Acked-by: Roman Gushchin . I'm ok with the current approach too (the one you posted), but the one above is preferable. Overall it would be nice to clarify & document our expectations from /proc/kpagecgroup (and /proc/kpageflags & /proc/kpagecount) in the new folio "epoch". Thanks!