Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3971317ybl; Mon, 3 Feb 2020 10:01:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxjZ9POvJ/s7CPxxa3fBYW8Yj/34g3BzbLFnQxJcC7dvSqnFQrLcfWvSXJ5rYQeeSJ0C4Rn X-Received: by 2002:a05:6808:358:: with SMTP id j24mr174153oie.89.1580752878294; Mon, 03 Feb 2020 10:01:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580752878; cv=none; d=google.com; s=arc-20160816; b=VfIJ7CWFP50fuF3kq7Qx+dIMk7ItyCT3xNXGq2vnVniT/NqCUypUS2mOMwQj/0IOLQ epm9EMjlGni2MeGNtqWuFA2LYesCmElbi74rsJPz8CQ9m0Q3Q1PDi+iByuYw9B1mGtp8 RdU5FESmOK59hTvxATbDZ2LA8AyMIcXJdmPO8i6Erx665O4YF1tWKx1g0XXG9Dnvkf2E ZI3dyiKPRVYtMKvIcQssNeOcGo/p+Zg7mfWokUdgw5mmi708sohWFf/kZioHTAD7Xf6d vVFZRyVOrexO2+voE3bjE5nmLOP5kVtxai1g0azQ9Ac+KcuRL44yKgZzZnfUQaBWEHbZ shoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=UE45wlqzCyQq4DipWwUCK35G6cE2qZRpII/okw53kug=; b=aEvpRTVdFCH3ycOsOwoOEVJTzfbGVF17/8RbwWv3muWVOrR9t71/HFeAorbeUyz/pb pazZV5qidQqvFKX2iILSVy85ejughpkDmysv0HWV3WECIK/zLtrdkEWzLqW5T7LNsOTg O2w5AoLPXTbmeMl1CxTGHhR9f+uJLbcApvT/513JU0gBnDstMwf5bxA/1SgCOAXKVaLT WdLrYa/TUJGakZNmZv8E7I7IZp1vZ7yGHsPx5Yhk40Sil/i1MOddCVkEYQQ5cfDBl+y6 weJYgAtw9+KnKyh1T5lM6P2lFQ446b0/wBQoVSomHOAcnKi/NzJeoXAhtQfkFhBbi4OM 6IuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=XMlXhfYN; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u206si4592130oia.224.2020.02.03.10.01.06; Mon, 03 Feb 2020 10:01:18 -0800 (PST) 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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=XMlXhfYN; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728048AbgBCQME (ORCPT + 99 others); Mon, 3 Feb 2020 11:12:04 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:39994 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727708AbgBCQME (ORCPT ); Mon, 3 Feb 2020 11:12:04 -0500 Received: by mail-qt1-f194.google.com with SMTP id v25so11833717qto.7 for ; Mon, 03 Feb 2020 08:12:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=UE45wlqzCyQq4DipWwUCK35G6cE2qZRpII/okw53kug=; b=XMlXhfYNGnmRvER9HoY+Xnnw0D/suIrufuWQl0h4duypoSxdwVuiLXbrkUforCoibD GhXuJfUSbCmHAbSs52G1+aKpEl//HosHAK7z3SPDVWiL7E3bfg5ga2YHl5EhbfOVb/Wk 42hKzfJvQYHLzrf/TMCJncMuoJBOzMGImede+/RJtPCdi71B3DseyvtZuhB33n+R8h0z rAXOGvgRUOKUuBAbw7V7vbqJd/LpLzsfZHVO0X3A2FZet8CBICxWabi8x1aAzifsH0r7 SjSbp316QZGdUO3NrYYOwcqIHyXad3g07ZO09bXhnjcvTNIhWzvzj3bqY9/H62YOptTB FasA== 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; bh=UE45wlqzCyQq4DipWwUCK35G6cE2qZRpII/okw53kug=; b=s2y6UH6ndzFyQ0dLvaq+XKkyIR14iETnuEwz2n2sAxGKxZRObZ/wy/kpYqUvfnmfbv J3FLRs8klPwBzEcni/RAuKAYtEdia37KkSUXENLOjiI4C/iTkoPjFfZL//gLu/Qj+ZmL kAUyzRfQ/u+6jGA6tsRsSOpZriPqBigJMfPPLOFeWtuhd2px31ZI1dN+sxdelJEZodEj 0ioq+baj5tIojieOpagTihslC8xpygUAv1Rt1iyuGfR+zw73ERlJk7u+FbXeUlhkowQs OZSgRurBVBHQmaTPUZ8i/nDoqVIGM7gAf7wmT29/2vp5MtZPx/pTwAjkxK5rdWzkXf+P Z/Rw== X-Gm-Message-State: APjAAAU+0radARN4tag2b/XXbXuSsW6l6/uRF0gw9RgQqQjHWQntj2Li AGoLS2Tc+DFfL2iDXoWifd3elg== X-Received: by 2002:ac8:1e8e:: with SMTP id c14mr22792744qtm.330.1580746321918; Mon, 03 Feb 2020 08:12:01 -0800 (PST) Received: from localhost ([2620:10d:c091:500::3:c810]) by smtp.gmail.com with ESMTPSA id i6sm9515899qkk.7.2020.02.03.08.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 08:12:01 -0800 (PST) Date: Mon, 3 Feb 2020 11:12:00 -0500 From: Johannes Weiner To: Roman Gushchin Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Shakeel Butt , Vladimir Davydov , linux-kernel@vger.kernel.org, kernel-team@fb.com, Bharata B Rao , Yafang Shao Subject: Re: [PATCH v2 08/28] mm: fork: fix kernel_stack memcg stats for various stack implementations Message-ID: <20200203161200.GB1697@cmpxchg.org> References: <20200127173453.2089565-1-guro@fb.com> <20200127173453.2089565-9-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200127173453.2089565-9-guro@fb.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 27, 2020 at 09:34:33AM -0800, Roman Gushchin wrote: > Depending on CONFIG_VMAP_STACK and the THREAD_SIZE / PAGE_SIZE ratio > the space for task stacks can be allocated using __vmalloc_node_range(), > alloc_pages_node() and kmem_cache_alloc_node(). In the first and the > second cases page->mem_cgroup pointer is set, but in the third it's > not: memcg membership of a slab page should be determined using the > memcg_from_slab_page() function, which looks at > page->slab_cache->memcg_params.memcg . In this case, using > mod_memcg_page_state() (as in account_kernel_stack()) is incorrect: > page->mem_cgroup pointer is NULL even for pages charged to a non-root > memory cgroup. > > In order to fix it, let's introduce a mod_memcg_obj_state() helper, > which takes a pointer to a kernel object as a first argument, uses > mem_cgroup_from_obj() to get a RCU-protected memcg pointer and > calls mod_memcg_state(). It allows to handle all possible > configurations (CONFIG_VMAP_STACK and various THREAD_SIZE/PAGE_SIZE > values) without spilling any memcg/kmem specifics into fork.c . The change looks good to me, but it sounds like this is a bug with actual consequences to userspace. Can you elaborate on that in the changelog please? Maybe add a Fixes: line, if applicable?