Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3335999pxu; Tue, 15 Dec 2020 04:44:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyV43wvpJWolE2qvtC2+OaHqFv35szmtyAW7uJZH3jvIYkYOrorg5eOnR+AfjN++sRqBs/1 X-Received: by 2002:a05:6402:1153:: with SMTP id g19mr29492283edw.312.1608036283277; Tue, 15 Dec 2020 04:44:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608036283; cv=none; d=google.com; s=arc-20160816; b=aLqFFfg7JP7ax7JoEPHevYi4FLfrzX6z1x+xG72u/kR9TJGICqvpQh+8kVdJXwsQdZ 0Pi+QYBSoeHrUyBPX7rvSETIr/sSIvGAZo4TQ0cY3qHZvF8FpYo1pVbwr7lUSLb1CINP FUdYFKHPoLqMaPvD15DhDqlumlRDKEj/AXKwL/pebdXzYW1iVljzuwxYv0lRzP6Dw+3h MJDRffkwBJBBPx244/ji5ZeWuIJcP8lMX4mmAJ8+b2a3tV7WS5ZoE5kbLQ+0d9SDtcQq VyqFSA0MKFCGMopiIYb+z0BlN93yX06INHAPtPUZslbGJoyo/ehBVkjc7wW9dc9Z1INr Tlmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=cg7Gn7dAZDw1ehWTCIK8wOa7MiG0DcwcKiNrTya0UkM=; b=aJO+r+GapYPyxwWkeAHftO+aZa4KXzFdRMdiFhMXrh/04TLaKjnQc5kpKWkc3Gibgh FBSGxNVx/m/g/zKFLs6CyUvaC6hmdYKnSyxuACqPagjbFOpYdxO6RMH+Keb3wzi6+JFk FVSRQllKBGt3JsJ12qEK8RIzDUODbKCjudLfCswFS4HdmSJSE3URGkgxpY/YzpVc2BEW vppJsgau7koxEfp9lAZACfPldCUy2kvC0bs/5RYXA3gJP92PwEpr7kEauFq7zeLB6A+d hPHfohT0+UZwKaIxN3uq9IZnDPzEbHz12GywwrZL9HHxcDLy26eJmTfVwV+gGVImMUZT gZyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=NWyfwITl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id h17si787463ejd.473.2020.12.15.04.44.15; Tue, 15 Dec 2020 04:44:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=NWyfwITl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728201AbgLOMky (ORCPT + 99 others); Tue, 15 Dec 2020 07:40:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725535AbgLOMky (ORCPT ); Tue, 15 Dec 2020 07:40:54 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2C24C0617A7 for ; Tue, 15 Dec 2020 04:40:13 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id lt17so27469848ejb.3 for ; Tue, 15 Dec 2020 04:40:13 -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=cg7Gn7dAZDw1ehWTCIK8wOa7MiG0DcwcKiNrTya0UkM=; b=NWyfwITlkuwr1CV1nsn0yOQJnM7y+4/l5Rw0QZtR1YBieaanbHXzPxGPqVai/DIkkZ N/qRivbDfWdGqR1iV6BtAxZh0iTH56AJ1uv3iaCDkexTblRk7oBnmfcfzZMtSBJF5XUE w3Vg0zZMZA0ksWQnTP71e6LXikB1KJTKIcW04qMix7k9Khks+POW9oe2OQluBaInbJ6h 6jPv+f4gKJGkORXQnAfkZMCSHNMPgPfuLKLp8//YdLZFOX21+VS4E3ZsZ+D9jHmBHN9k GxXOdvu52l01iTfn8ztlyo80SiKcK1pcIzNYw4svthSFsDjBXx+zdMTEbQCnqudHY4cd DyJg== 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=cg7Gn7dAZDw1ehWTCIK8wOa7MiG0DcwcKiNrTya0UkM=; b=awpGCu1hqiXYxdhP8DOCCRTKaPpFRWsU+6ygZt+kQSYpebLjhEpffH0TwKllBzc6M4 eKEL2Dbqk6Y1itpotVc1lrjjNx9AW4WLjwMNmQ2qJvbYW2RJP3h55CF/O1+OMeyTBDGW dJU9hi/vmRUXaLmTeOl6w9ozHfPYFiImXBKVsMCGud+B2QWhHGMayhgPy8dzi4/SCA+Q UafGqp0LW3c0y3kZjKuhFXruIawtf4ijnwymSRgOxmr4g6nHnZeJedGkYbL0R4SpP/5t IvjFwjjd903IcsDkM8UKj1SRbnytJNjiZDslm6lrxmXwQXZkHii6dxKyq7AO+6fT0deV Rvhw== X-Gm-Message-State: AOAM531sEHih4C5XArtp3mcHu6xdgtqvSaI7qodOvYpgReS6mxEzVazl yTyuK2DhM9kuqsCKKr49ZFSg+g== X-Received: by 2002:a17:906:d62:: with SMTP id s2mr27036601ejh.61.1608036011994; Tue, 15 Dec 2020 04:40:11 -0800 (PST) Received: from localhost ([2620:10d:c093:400::5:d6dd]) by smtp.gmail.com with ESMTPSA id x20sm1276312ejv.66.2020.12.15.04.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 04:40:10 -0800 (PST) Date: Tue, 15 Dec 2020 13:38:02 +0100 From: Johannes Weiner To: Yang Shi Cc: guro@fb.com, ktkhai@virtuozzo.com, shakeelb@google.com, david@fromorbit.com, mhocko@suse.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [v2 PATCH 3/9] mm: vmscan: guarantee shrinker_slab_memcg() sees valid shrinker_maps for online memcg Message-ID: <20201215123802.GA379720@cmpxchg.org> References: <20201214223722.232537-1-shy828301@gmail.com> <20201214223722.232537-4-shy828301@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201214223722.232537-4-shy828301@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 14, 2020 at 02:37:16PM -0800, Yang Shi wrote: > The shrink_slab_memcg() races with mem_cgroup_css_online(). A visibility of CSS_ONLINE flag > in shrink_slab_memcg()->mem_cgroup_online() does not guarantee that we will see > memcg->nodeinfo[nid]->shrinker_maps != NULL. This may occur because of processor reordering > on !x86. > > This seems like the below case: > > CPU A CPU B > store shrinker_map load CSS_ONLINE > store CSS_ONLINE load shrinker_map > > So the memory ordering could be guaranteed by smp_wmb()/smp_rmb() pair. > > The memory barriers pair will guarantee the ordering between shrinker_deferred and CSS_ONLINE > for the following patches as well. > > Signed-off-by: Yang Shi As per previous feedback, please move the misplaced shrinker allocation callback from .css_online to .css_alloc. This will get you the necessary ordering guarantees from the cgroup core code. Thanks