From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D8C5C4361B for ; Tue, 15 Dec 2020 17:16:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9F98F229C5 for ; Tue, 15 Dec 2020 17:16:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F98F229C5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D1D016B0068; Tue, 15 Dec 2020 12:16:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CCD656B006C; Tue, 15 Dec 2020 12:16:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6E5A6B006E; Tue, 15 Dec 2020 12:16:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0143.hostedemail.com [216.40.44.143]) by kanga.kvack.org (Postfix) with ESMTP id A14056B0068 for ; Tue, 15 Dec 2020 12:16:49 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 570CB180AD830 for ; Tue, 15 Dec 2020 17:16:49 +0000 (UTC) X-FDA: 77596171338.16.seat53_3b17b1427425 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 35586100E6903 for ; Tue, 15 Dec 2020 17:16:49 +0000 (UTC) X-HE-Tag: seat53_3b17b1427425 X-Filterd-Recvd-Size: 4581 Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Dec 2020 17:16:48 +0000 (UTC) Received: by mail-ej1-f65.google.com with SMTP id ga15so28790774ejb.4 for ; Tue, 15 Dec 2020 09:16:48 -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=yKB5P3mmMeccCVq/i2dQ6a1JB3M5e9Un7Ow5i/UnWnM=; b=zA5A/pRfIGe07vij4DySDUNXt3hgH73LPDdRgKaBBAACVFoNgxY22zOM7GP3MmMhYB 2FQnEUV0TsjZkJ3s4aWTOvRVinmxuDRMe7n7ShuAoxTviyZUA6qf218W7cq3WzXeQIfF TDbPmUP7swZqJXRGQ+LJX3ygthciPd9sbzqcF+q6PgW5PhMAo+36mjNAb+EO1t0jhUdy eMqS18FNCvjazQYxVQ0DEtmAqRe/6zoEUN22fLXP1oWbxT4kzEUnaJKzePjcYmgoDHyu PA9wSgVvbHJi720EjncVezvahEqjjBnRT6GCDHFkG9uMWoIu8KzrwLdbhqBx4iFYv+/s pD4Q== 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=yKB5P3mmMeccCVq/i2dQ6a1JB3M5e9Un7Ow5i/UnWnM=; b=eNxgQUI0lPIFIMe63uvkc/WYvmyA23ehqutrZxpNA303WRiR2C+WIShQDucJ1I7KoU wffygqfuR2xqlU7sE1llq5gjJcC58Wf0QlHQwlXoNOXtWeVlmkseXywoSA2QWopFT106 y3H8o1JzVS9QQqrWRFgu6JMhRlF68kshiqTheYBDVY2HsJ8kunnOLTBSiEmrYSP5Sjjl Ghig7kpWE75lNJpVj8KGF1DVtyaBCJk+Jx7IT/JWubu1u6AJra3WgKhJ06IqRiE/k893 NLdRyHB+F0bETjFiQV+CjJKu7pgU0J9oldumqF4n1kTl6lGo9VU2rlSy26PNCfzJFVPu QbiQ== X-Gm-Message-State: AOAM532MTdsCi17+sA12rJpF3KcFw5+gxSGmLd59GXb80sx2nLaJrHPB P6CgMWKtzbb7BdyNpobjN9awAQ== X-Google-Smtp-Source: ABdhPJx9oFI8c9NRCINhaYG2c8gjCFS/T3A9/B5lRKTP1ltaeZSxYbQLlICQTj8j2vsLhSYLIbYb1A== X-Received: by 2002:a17:906:a181:: with SMTP id s1mr14149482ejy.60.1608052607054; Tue, 15 Dec 2020 09:16:47 -0800 (PST) Received: from localhost ([2620:10d:c093:400::5:d6dd]) by smtp.gmail.com with ESMTPSA id z24sm18899199edr.9.2020.12.15.09.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 09:16:46 -0800 (PST) Date: Tue, 15 Dec 2020 18:14:39 +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: <20201215171439.GC385334@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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 But we have a separate check on shrinker_maps, so it doesn't matter that it isn't guaranteed, no? The only downside I can see is when CSS_ONLINE isn't visible yet and we bail even though we'd be ready to shrink. Although it's probably unlikely that there would be any objects allocated already... Can somebody remind me why we check mem_cgroup_online() at all? If shrinker_map is set, we can shrink: .css_alloc is guaranteed to be complete, and by using RCU for the shrinker_map pointer, the map is also guaranteed to be initialized. There is nothing else happening during onlining that you may depend on. If shrinker_map isn't set, we cannot iterate the bitmap. It does not really matter whether CSS_ONLINE is reordered and visible already. Agreed with Dave: if we need that synchronization around onlining, it needs to happen inside the cgroup core. But I wouldn't add that until somebody actually required it.