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=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 5D688C432BE for ; Mon, 16 Aug 2021 08:34:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F1E5061B25 for ; Mon, 16 Aug 2021 08:34:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F1E5061B25 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 91DB36B0073; Mon, 16 Aug 2021 04:34:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CD566B0074; Mon, 16 Aug 2021 04:34:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E2ED8D0001; Mon, 16 Aug 2021 04:34:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id 61C3A6B0073 for ; Mon, 16 Aug 2021 04:34:27 -0400 (EDT) Received: from smtpin33.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 10B851F35F for ; Mon, 16 Aug 2021 08:34:27 +0000 (UTC) X-FDA: 78480282174.33.FBF7741 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf04.hostedemail.com (Postfix) with ESMTP id 5BAAE500CD79 for ; Mon, 16 Aug 2021 08:34:26 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id DFA1F61B23; Mon, 16 Aug 2021 08:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1629102865; bh=3YEutj3bDMCaJ4+ve9fprNnWP2Ew89/JAaSv3hfe95A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pw2xK9Dgx6nK8n8BF8fUTZK6n/HfSrKYjtArjqeA6jiMcM1XmISfaJe+sV2cPW4Aj Z1hGfv9QBfjRhHkYKqIUfbCitWjEXn+FDsq4UWy4E81FGSJFhPWhK5f0VMbBz/bSSD 2jsv6OjeLMvstIWSHrdpefBMJc7veH1wPFQv1++E= Date: Mon, 16 Aug 2021 10:34:22 +0200 From: Greg Kroah-Hartman To: Chen Huang Cc: Roman Gushchin , Muchun Song , Wang Hai , linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, Andrew Morton , Alexei Starovoitov Subject: Re: [PATCH 5.10.y 01/11] mm: memcontrol: Use helpers to read page's memcg data Message-ID: References: <20210816072147.3481782-1-chenhuang5@huawei.com> <20210816072147.3481782-2-chenhuang5@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210816072147.3481782-2-chenhuang5@huawei.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 5BAAE500CD79 X-Stat-Signature: 1xaz188f45ruy4knergrdybymrz9gn44 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=pw2xK9Dg; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf04.hostedemail.com: domain of gregkh@linuxfoundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-HE-Tag: 1629102866-672469 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, Aug 16, 2021 at 07:21:37AM +0000, Chen Huang wrote: > From: Roman Gushchin What is the git commit id of this patch in Linus's tree? > > Patch series "mm: allow mapping accounted kernel pages to userspace", v6. > > Currently a non-slab kernel page which has been charged to a memory cgroup > can't be mapped to userspace. The underlying reason is simple: PageKmemcg > flag is defined as a page type (like buddy, offline, etc), so it takes a > bit from a page->mapped counter. Pages with a type set can't be mapped to > userspace. > > But in general the kmemcg flag has nothing to do with mapping to > userspace. It only means that the page has been accounted by the page > allocator, so it has to be properly uncharged on release. > > Some bpf maps are mapping the vmalloc-based memory to userspace, and their > memory can't be accounted because of this implementation detail. > > This patchset removes this limitation by moving the PageKmemcg flag into > one of the free bits of the page->mem_cgroup pointer. Also it formalizes > accesses to the page->mem_cgroup and page->obj_cgroups using new helpers, > adds several checks and removes a couple of obsolete functions. As the > result the code became more robust with fewer open-coded bit tricks. > > This patch (of 4): > > Currently there are many open-coded reads of the page->mem_cgroup pointer, > as well as a couple of read helpers, which are barely used. > > It creates an obstacle on a way to reuse some bits of the pointer for > storing additional bits of information. In fact, we already do this for > slab pages, where the last bit indicates that a pointer has an attached > vector of objcg pointers instead of a regular memcg pointer. > > This commits uses 2 existing helpers and introduces a new helper to > converts all read sides to calls of these helpers: > struct mem_cgroup *page_memcg(struct page *page); > struct mem_cgroup *page_memcg_rcu(struct page *page); > struct mem_cgroup *page_memcg_check(struct page *page); > > page_memcg_check() is intended to be used in cases when the page can be a > slab page and have a memcg pointer pointing at objcg vector. It does > check the lowest bit, and if set, returns NULL. page_memcg() contains a > VM_BUG_ON_PAGE() check for the page not being a slab page. > > To make sure nobody uses a direct access, struct page's > mem_cgroup/obj_cgroups is converted to unsigned long memcg_data. > > Signed-off-by: Roman Gushchin > Signed-off-by: Andrew Morton > Signed-off-by: Alexei Starovoitov > Reviewed-by: Shakeel Butt > Acked-by: Johannes Weiner > Acked-by: Michal Hocko > Link: https://lkml.kernel.org/r/20201027001657.3398190-1-guro@fb.com > Link: https://lkml.kernel.org/r/20201027001657.3398190-2-guro@fb.com > Link: https://lore.kernel.org/bpf/20201201215900.3569844-2-guro@fb.com > > Conflicts: > mm/memcontrol.c The "Conflicts:" lines should be removed. Please fix up the patch series and resubmit. But note, this seems really intrusive, are you sure these are all needed? What UIO driver are you using that is showing problems like this? thanks, greg k-h