Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp229719imm; Tue, 14 Aug 2018 17:56:07 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx2kodh8Jjp4XSk2DcWYZJmYYz5BcDOnigcXULhgpcNGVpl/VlbEMIge7QP8painErX3svT X-Received: by 2002:a62:25c5:: with SMTP id l188-v6mr25472174pfl.179.1534294567295; Tue, 14 Aug 2018 17:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534294567; cv=none; d=google.com; s=arc-20160816; b=qrkLxGZN4PftPBT/+ThmBMn9luAS/PeIHG3mXTHo+qivLuXijKi4noNqI35OTSUq1j mBaLcYWHIzboYzSREYYr2uDyjlYOzrNQEeOQ7hZSlI04FGPcXFxxh7tT2azyLS6BIGSw w6/YhzT3AiSr/l+vN+ZKWeEoAg6dpiVzFDNXAp/aRIYp2sLpqi7l4lB4p/jBCQd/WX9E hus5xS3Dmbi6i/GA8Wx9NMLHrVPLpcq8rWstBijnfPcDSAS5kBl7XigfdPqR88Mm/cA7 Lr5z00xcMWS16e1hwDp5gEydzSW6O/3NnxiULfLJcrF9OnCwPViUTj05892aHGmfgHRA 42/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=dX0CVZZvtGH4f6rcdWiWNjUoyMOI49TL6gi8/xzmnbk=; b=Vr02A+qwdzH/iHIDWNTxRYQsTAbgshSD9u1aD4S31QHLCh3i+0nZ1zmdXMrz5OfyVP f6wSsQCoZTXyS1LTkMBGGD5UnUCFlQiWJZjBfiNuhWKBUw/Up8gVlI2X5VinPKPBC03a NTRpt1s62zgr/1gRd58zRG71smT0ZjDH2Y9wrUEzlo8y08A+GCYBn1Npd/m32AXAuQTp GPPJWYA7ir+U3xNEV7FwjEOenkLDr/AELJu6L8sZMob/jHR4Fr9CyoU9NiMWJMWSgnZ1 K/FmZwRG2SFGyrpUU7E6NXXhp7drDWRuzBwa+gnLDDMIRNdno7HvrgXF2BOJBCtPOf9x Swjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=a29LUaus; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j67-v6si19175636pgc.186.2018.08.14.17.55.52; Tue, 14 Aug 2018 17:56:07 -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=@google.com header.s=20161025 header.b=a29LUaus; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728397AbeHODoL (ORCPT + 99 others); Tue, 14 Aug 2018 23:44:11 -0400 Received: from mail-ua1-f68.google.com ([209.85.222.68]:46287 "EHLO mail-ua1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728347AbeHODoK (ORCPT ); Tue, 14 Aug 2018 23:44:10 -0400 Received: by mail-ua1-f68.google.com with SMTP id u11-v6so15274555uan.13 for ; Tue, 14 Aug 2018 17:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dX0CVZZvtGH4f6rcdWiWNjUoyMOI49TL6gi8/xzmnbk=; b=a29LUausvSSgLJlVptuV2yuIju5fVJ6ukcKEJGfPF07ydBzNNvc1IXVnVzaZlfkArZ bDUY9MXtEr6XdnlIcF3jMr9E42g4QD+rrLLVtPShhHcMrDvCqz2Tp1bBtXvKQK1WgJKx RggGusgMBncHp4aGBj+WkfOumgj/D0AIyduHz6njNOagYr11WPYaHzZIQHENd6ELXIdV DBEJbzGL0VG/CIqjyVN23SjlEw5yE7YTTPiFLeV0euTIBLTRl9xD7kdwVIwzZHpKA2XW kBSi/GI8pBNgXkwzRA/kblM4kkUT3LhHijo1vyH/QdnBO5u2EgIPUVg45n+j6Uwd+Rx5 N3Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dX0CVZZvtGH4f6rcdWiWNjUoyMOI49TL6gi8/xzmnbk=; b=QUFBxjflMClgqQVvl+qxQY5uiK10pW1/tkNY6AHFlmQ3ceuWZlylgKb5DapQZIkpeT E1FIaDegWnz67JKl5zlzLa1zOtAZ4qE743j/3No3LYK7dbPumu27eoi3gJ8xMTSDPOOQ QOdMoG5LNwJkd1srRsaJtWdEJO+WV2UlYAYPqeiH8AbO1uVY9WQevvWsgPBUq+WNdr6l 3g77ocIwjoAywoNKuxNxbLeSBp6Gj2Kci4MxwTQEWC5p3t+9hHFezPGItpN4sTQjX7d/ 1vnD/CWQE3goAZaY2y5qV68AnlukH2SgojJd7Cu7VmPo9F4cZ5HWhzUAmit4CkbG0xrx vSSg== X-Gm-Message-State: AOUpUlG5yVVw0Hg7A1xBUo+uktjyi3LyLv/rHd+iKs+fePKUOoM6JXiY SPvx8YEjJ6YLqQBW0uAzKG1OP1Yz8i0vG+WNyhQ3WA== X-Received: by 2002:a1f:ec02:: with SMTP id k2-v6mr15579549vkh.81.1534294464585; Tue, 14 Aug 2018 17:54:24 -0700 (PDT) MIME-Version: 1.0 References: <20180815003620.15678-1-guro@fb.com> <20180815003620.15678-2-guro@fb.com> In-Reply-To: <20180815003620.15678-2-guro@fb.com> From: Shakeel Butt Date: Tue, 14 Aug 2018 17:54:13 -0700 Message-ID: Subject: Re: [RFC PATCH 2/2] mm: drain memcg stocks on css offlining To: Roman Gushchin Cc: Linux MM , LKML , kernel-team@fb.com, Johannes Weiner , Michal Hocko , koct9i@gmail.com, Tejun Heo Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 14, 2018 at 5:36 PM Roman Gushchin wrote: > > Memcg charge is batched using per-cpu stocks, so an offline memcg > can be pinned by a cached charge up to a moment, when a process > belonging to some other cgroup will charge some memory on the same > cpu. In other words, cached charges can prevent a memory cgroup > from being reclaimed for some time, without any clear need. > > Let's optimize it by explicit draining of all stocks on css offlining. > As draining is performed asynchronously, and is skipped if any > parallel draining is happening, it's cheap. > > Signed-off-by: Roman Gushchin Seems reasonable. Reviewed-by: Shakeel Butt > Cc: Johannes Weiner > Cc: Michal Hocko > Cc: Konstantin Khlebnikov > Cc: Tejun Heo > --- > mm/memcontrol.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 4e3c1315b1de..cfb64b5b9957 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -4575,6 +4575,8 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css) > memcg_offline_kmem(memcg); > wb_memcg_offline(memcg); > > + drain_all_stock(memcg); > + > mem_cgroup_id_put(memcg); > } > > -- > 2.14.4 >