Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3137834ybh; Mon, 5 Aug 2019 12:46:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyb2rmR7kw1WedfQHt7FImM8onHLBgrKm8B1JOLqZQnWXnKFfp4jjzokJbUIXSlUc1PBIAb X-Received: by 2002:a62:e910:: with SMTP id j16mr76714584pfh.123.1565034366530; Mon, 05 Aug 2019 12:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565034366; cv=none; d=google.com; s=arc-20160816; b=lqNFloFQrWxh+THI8EbMfcLGQTDqwirxfGTlDy8Cx22Ngl8NsLG9zCeLTIg0cnrj18 GBTjDXD/tZYVvUDb6c1dQ61bnCWxBOoHCjmifX+m4Rn9miTg/b+NNrPOrEPS1dkwZIDa n+PBN8FJONl6lYN2NTGCMOQyg0aJNZned8eUhjcdMR1QWf1TvjO18EU8EdDXewxQoy1E tJA9fTLOCaEBs81xo6TAuyiAsiwTza7dkL4XBnh3s3bZTVnG6+X2jcpnNZkviu865FfD gzZdynDo4SumfoLCWfJbVCMILqd+LsZi6Yxtj5mSCsB6VekSJWyfgBhmZx5hFaS9OQRv V49A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WWvuvR2gfG7sLdu6K+RYuoog4fh46SnlfKdpfISWizo=; b=pZoXa4cFKG5uAh6YT9R6a0Mg0xUatRS5kZhe9RysxJgAVU1A9h+Ov+GYfAUXfbaOOU CrhgmetAXkjRom1R6emepMNcZNdemMO/bwmTvmv59oDoqecyQ7SxMlYzKRapgGCfO+nH /AGcO/kunhGE2S3oIP+yiT+px72+zdJ37qCcPkcRKTg6aKeX7Xh5E6989lWOBmdrX6ZD 48uc3xNl+/TRrej0vG1+eRDMuukuWnrk8PH+SbMWPgc1KdVvDn/O8rQZquIg2/N9nPqj 0BAF+3Uj0Xj6NzhwJE6fxURAnMCAcEy4X/mUl2ijHfh60PwfANTPwvsTmTPBI+bge1mc 11eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="FF0ThfX/"; 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 26si47160414pgs.520.2019.08.05.12.45.50; Mon, 05 Aug 2019 12:46:06 -0700 (PDT) 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="FF0ThfX/"; 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 S1730457AbfHETnp (ORCPT + 99 others); Mon, 5 Aug 2019 15:43:45 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35005 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727460AbfHETno (ORCPT ); Mon, 5 Aug 2019 15:43:44 -0400 Received: by mail-pg1-f195.google.com with SMTP id n4so4981212pgv.2 for ; Mon, 05 Aug 2019 12:43:44 -0700 (PDT) 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:user-agent; bh=WWvuvR2gfG7sLdu6K+RYuoog4fh46SnlfKdpfISWizo=; b=FF0ThfX/bzXj/27mCqPHlsBMwiIYZlOM9RmNphVdMiLTKFTSIINwJ461YEYbUUwEJN m26UyZ3XWL77w/tHksUHW1PeyGzJyWNY13DjAPzELJZneSPxWuZasvz9dNFt6/2JPtgv qVIywLEuv+OpFrpLPJjL+0VyhOS8hmp386H5C28ioO5TYQorFdFX3xnvENVjSQvV2tyZ q5GaWw0MT+HdTeGMxeem1WwEcjvhWzGYE8bRKhHOmp1odj0KsF0vBeTfIHRfi7j/yTkA pxF6+yVEj8pUlTHwytLp4HNKWrEMSHivN64CPzymFxxqOyFjW9elvIgLCJFiY5lCLGUn dOzg== 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=WWvuvR2gfG7sLdu6K+RYuoog4fh46SnlfKdpfISWizo=; b=ABhGdJmQ9jHCjaCXterjNCYtFFr7Kk9IeNOD+5tCeEJJ3IexJV3ONKMeV5owfVn92s OpnlrzHl+EqYel5jugjQi107y3QvLaJcoM7q/FJSae+Mvw37H6s16g0SDwJ7ezAIW7vS C1y9QLcrk1ZR0qxJySwrqkEg7cqDmAa15ZZI1ekgIrKPauTXbLeCfr9351EfMGYkWJtm p+M7xYn1swF4UcYDecZqDQ2BMA0rCvXb9ftztdY89NN26p6IHt3QVHw0F9qf+PMz7s1k cUT4NVczM1CZqFDlMGfSxR5I6+dD+h7CgXZs73MlHUTUHrIwc0aozjT1ga33AoweEksF HKsQ== X-Gm-Message-State: APjAAAUueYeyb0TJqFTcy3IWmWuyMVY9dS7HB+o3Dr+iItIUi4nDNIhM m0phZUsf56JvREj8fWEIZPE= X-Received: by 2002:a62:6083:: with SMTP id u125mr73381751pfb.208.1565034223953; Mon, 05 Aug 2019 12:43:43 -0700 (PDT) Received: from localhost ([2620:10d:c091:500::26a1]) by smtp.gmail.com with ESMTPSA id h26sm89520864pfq.64.2019.08.05.12.43.42 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 12:43:43 -0700 (PDT) Date: Mon, 5 Aug 2019 15:43:41 -0400 From: Johannes Weiner To: Roman Gushchin Cc: Andrew Morton , linux-mm@kvack.org, Michal Hocko , linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH] mm: workingset: fix vmstat counters for shadow nodes Message-ID: <20190805194341.GA6260@cmpxchg.org> References: <20190801233532.138743-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190801233532.138743-1-guro@fb.com> User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 01, 2019 at 04:35:32PM -0700, Roman Gushchin wrote: > Memcg counters for shadow nodes are broken because the memcg pointer is > obtained in a wrong way. The following approach is used: > virt_to_page(xa_node)->mem_cgroup > > Since commit 4d96ba353075 ("mm: memcg/slab: stop setting page->mem_cgroup > pointer for slab pages") page->mem_cgroup pointer isn't set for slab pages, > so memcg_from_slab_page() should be used instead. > > Also I doubt that it ever worked correctly: virt_to_head_page() should be > used instead of virt_to_page(). Otherwise objects residing on tail pages > are not accounted, because only the head page contains a valid mem_cgroup > pointer. That was a case since the introduction of these counters by the > commit 68d48e6a2df5 ("mm: workingset: add vmstat counter for shadow nodes"). You're right. slub uses order-2 compound pages for radix_tree_node, so we've been underreporting shadow nodes placed in the three tail pages. Nice catch. > Fixes: 4d96ba353075 ("mm: memcg/slab: stop setting page->mem_cgroup pointer for slab pages") > Signed-off-by: Roman Gushchin > Cc: Johannes Weiner > Cc: Andrew Morton Acked-by: Johannes Weiner