Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp689264ybl; Wed, 14 Aug 2019 04:34:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqziC+Zw2mfn6awUuDpxqr7DO44uyo9NJjESgiSsH1V0Z7/GHlX36KP83kfxCTxg63Q3jMTj X-Received: by 2002:aa7:9edc:: with SMTP id r28mr13415481pfq.219.1565782497398; Wed, 14 Aug 2019 04:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565782497; cv=none; d=google.com; s=arc-20160816; b=uv63hPjjRXMloDfEc8MNOee4Zv/IuM/q+yXdOSLhPsDkBRJoAd+wVXdUWSDa9AQLv2 rw2wi9ObAcj+BXpr7Up/POMFZb+eyi08NDCL5TiN9GkivQrFAHMETkv8ss/TXcf1TlVO D77GEYp1k+JRhEI7F+wXMoDmJhrK829f+yPGObmRv2dBU2bvo1pYknff4sOHFeSGxqaa pNNEf8cSv1JUW/B2OGvOkABzOQBjHZ7VX3J1FtkSg8uopCobASZKmBZ7INx/a5FLx49+ oediMRLPyYleXNnkGr5FrDGSdnUSjOWXyAqNm3MG/7mEsxvfze6AY6+p44z+MfETfaWA 4PzQ== 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; bh=QNEjaIlKBmh4p4hgIYClI3ff5PeeitRml/2N01W/FYk=; b=mD/JudduX9Q48XNB2gyRUL/BOpXphkTCabZGrc8+Q1rWjfVP3oO+1ieBhj9hdWjl59 PdGsHrxz5zJhsvRMTwgRBNbvCRvOAdvfOFi9PCSLR3zeV+8eeLPkTqdmSjgeIFQi8kgT ieCz1iaPOWbGmMGsV+xDEll5mRZBmIVDJufsa/xfAkYZRADG2ygkF88ejQqKxro/WubJ C+p8pxbe/TDyvKhzxFDI5Z/yRYvKSlVA99S1Zg6qAxlt/6nJr2HcpUJn7imc5Gdqzmvu K+795qVXmE5W3w0uYaNtBEy8NmnjhUx+tr24lRrfCURs9aOVs4u31XGzocrsXgbhKH1m 259A== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j190si69325716pge.92.2019.08.14.04.34.41; Wed, 14 Aug 2019 04:34:57 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727766AbfHNLcp (ORCPT + 99 others); Wed, 14 Aug 2019 07:32:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:40342 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727617AbfHNLcp (ORCPT ); Wed, 14 Aug 2019 07:32:45 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6F9C7AEA5; Wed, 14 Aug 2019 11:32:43 +0000 (UTC) Date: Wed, 14 Aug 2019 13:32:42 +0200 From: Michal Hocko To: Roman Gushchin Cc: Andrew Morton , linux-mm@kvack.org, Johannes Weiner , linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 2/2] mm: memcontrol: flush percpu slab vmstats on kmem offlining Message-ID: <20190814113242.GV17933@dhcp22.suse.cz> References: <20190812222911.2364802-1-guro@fb.com> <20190812222911.2364802-3-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190812222911.2364802-3-guro@fb.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 12-08-19 15:29:11, Roman Gushchin wrote: > I've noticed that the "slab" value in memory.stat is sometimes 0, > even if some children memory cgroups have a non-zero "slab" value. > The following investigation showed that this is the result > of the kmem_cache reparenting in combination with the per-cpu > batching of slab vmstats. > > At the offlining some vmstat value may leave in the percpu cache, > not being propagated upwards by the cgroup hierarchy. It means > that stats on ancestor levels are lower than actual. Later when > slab pages are released, the precise number of pages is substracted > on the parent level, making the value negative. We don't show negative > values, 0 is printed instead. So the difference with other counters is that slab ones are reparented and that's why we have treat them specially? I guess that is what the comment in the code suggest but being explicit in the changelog would be nice. [...] > -static void memcg_flush_percpu_vmstats(struct mem_cgroup *memcg) > +static void memcg_flush_percpu_vmstats(struct mem_cgroup *memcg, bool slab_only) > { > unsigned long stat[MEMCG_NR_STAT]; > struct mem_cgroup *mi; > int node, cpu, i; > + int min_idx, max_idx; > > - for (i = 0; i < MEMCG_NR_STAT; i++) > + if (slab_only) { > + min_idx = NR_SLAB_RECLAIMABLE; > + max_idx = NR_SLAB_UNRECLAIMABLE; > + } else { > + min_idx = 0; > + max_idx = MEMCG_NR_STAT; > + } This is just ugly has hell! I really detest how this implicitly makes counters value very special without any note in the node_stat_item definition. Is it such a big deal to have a per counter flush and do the loop over all counters resp. specific counters around it so much worse? This should be really a slow path to safe few instructions or cache misses, no? -- Michal Hocko SUSE Labs