Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2839848imm; Wed, 16 May 2018 21:50:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqLr6CIKlLFF9aXAA2awjHwMzpppwiDs7cNL97aJ6ZmH5zFEl55S0wY5TX0GhaaDdUTyv5q X-Received: by 2002:a63:a51b:: with SMTP id n27-v6mr3041365pgf.47.1526532619175; Wed, 16 May 2018 21:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526532619; cv=none; d=google.com; s=arc-20160816; b=Rcrg4P/o3C6rw273Wf4t6gXI8vQ6znuRn1XxriUjqidZ1zm3YzaQB4hJv1Ke3J6ePc iLKsFIWWn+CLhkDaLk0h5MIJtWsXPauFCsZbNHm/XGmIYOezyXgjfdFzAG9Mlo7NSYee wKkMX31RywVjMQUgAjVdgAYIOkTxz4ZPFImA6/iiVmGVQigdnOze55jNE9Fu9mnepT8z 4A4HEaUZKA+QHIa3uEtLo8gV3FWtH+ZA7qpDADxzZeH58SnK7RFDSYA4EeslH/QNncL+ AhKEh8VMguLydLAsT2YCY0W38c4eIYnPnFIXoUrtEM+eqYrtmuFNOjSQEiWLkL9rJJuU 9b9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=OuPWy/QAMfwIaUFd7hU+2NmnB5S/aypwOQxJZehlRK0=; b=UAx6Z+ZFiOU415HU1GdsjoCeWC7iuWALu0WR+POnhOUrjN/aC8aGi0wLhp+5DLgEhW RCaIk4UNsaFS7U8KmFjZ0duXn4YV56+DeLZk/XMtW56YwMuC+M53gc3aGhCsbsHrVRSA 26EbpQlI1oUcxNDkN7x0Qkdt2Bkku3C2TQ7CKM5hyzv2VYHQjXk5NDlWVpY7a4jhGooF SvBC9knuM2wXCVTjB4mlsM2d7qYRH4wnmuoKOZwPfwmdjahwpELe3dPz4x2CBI9pxeBd YdgOF02Sj3IT6FKZQfO4PnnVJC9L/kukt3bIh0BjcvEeLxwdd7De8rU7Zafb4oghH4rK MlJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=F/7VFC/o; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4-v6si4134607plb.251.2018.05.16.21.49.51; Wed, 16 May 2018 21:50:19 -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=@gmail.com header.s=20161025 header.b=F/7VFC/o; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751280AbeEQEta (ORCPT + 99 others); Thu, 17 May 2018 00:49:30 -0400 Received: from mail-lf0-f49.google.com ([209.85.215.49]:41392 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750865AbeEQEt3 (ORCPT ); Thu, 17 May 2018 00:49:29 -0400 Received: by mail-lf0-f49.google.com with SMTP id m17-v6so6708116lfj.8 for ; Wed, 16 May 2018 21:49:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=OuPWy/QAMfwIaUFd7hU+2NmnB5S/aypwOQxJZehlRK0=; b=F/7VFC/o6fFFUMTEkgzVKFL42k19ROEPSispJgGQwKGNFxHu2bgk+H0n6cY4zqFJfM AbDkytHIdrIv2DZAMh4H6EWBLXygZFQ10N4XElhA5qOpCdLSVb7mSJqit1biWaOOIhNx YC+Jx9MdmuWAvvPwTv8KXnGAqwSTctHlSFKhgvyL8PNV3UPI95O2G8tY13y7c3M6jmhu 5qYFkftxpGyiI3puY74HKAE0nK80tVAGiusYZfYpN2EQiyVDRKjvTvXETUdKD5iglThK 1jwNSe2kIPGVMxlGnkdHgih9wyglIECSieE6nW23LDSMNimp9AUrQTKVdL4XabT2Uecg ZC7Q== 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=OuPWy/QAMfwIaUFd7hU+2NmnB5S/aypwOQxJZehlRK0=; b=MszelU5ZfsFZjCGd64waLBm7cuTYsdbrwb8Gg75hl8jsBHTh/2hp25bbw+it62/YNS TGhHcHh4ietvEIp9I7KW+YXefXiNfRN7IvxffKOegiNa2qqknhRDrcksoNFfki+/kP9Q GNjj0xTF7ouMAGi4AVTlqLJO50N9JxTcWnz13Ypy/vwz4GjhxZp5yvQAbZJRZSUdjAA1 wqZl5dX18QSEeaPHQ2WwrfDwiJX9BqEA4F1i9alX/3ydTcqtLWdTxGESHpGmboLv6KpH WFAekxWTMjCsrMj6Zy5K1n6UCp/hv+MmgF0CPpOZg1LyzcfX0k0U2SRHUfgsv1mThIyV kexQ== X-Gm-Message-State: ALKqPwerMaa7x+mg3cU+Qe25r0lGJJQ6e6ziTsTvL0GefPKk68GYUae+ DORWyJCRXGeKBG0WF+gB7jI= X-Received: by 2002:a19:e49b:: with SMTP id x27-v6mr11945467lfi.59.1526532567702; Wed, 16 May 2018 21:49:27 -0700 (PDT) Received: from esperanza (81.5.110.211.dhcp.mipt-telecom.ru. [81.5.110.211]) by smtp.gmail.com with ESMTPSA id j11-v6sm653799ljb.74.2018.05.16.21.49.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 21:49:27 -0700 (PDT) Date: Thu, 17 May 2018 07:49:24 +0300 From: Vladimir Davydov To: Kirill Tkhai Cc: akpm@linux-foundation.org, shakeelb@google.com, viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, tglx@linutronix.de, pombredanne@nexb.com, stummala@codeaurora.org, gregkh@linuxfoundation.org, sfr@canb.auug.org.au, guro@fb.com, mka@chromium.org, penguin-kernel@I-love.SAKURA.ne.jp, chris@chris-wilson.co.uk, longman@redhat.com, minchan@kernel.org, ying.huang@intel.com, mgorman@techsingularity.net, jbacik@fb.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, lirongqing@baidu.com, aryabinin@virtuozzo.com Subject: Re: [PATCH v5 13/13] mm: Clear shrinker bit if there are no objects related to memcg Message-ID: <20180517044924.5tq6vbqituvr3nzh@esperanza> References: <152594582808.22949.8353313986092337675.stgit@localhost.localdomain> <152594605549.22949.16491037134168999424.stgit@localhost.localdomain> <20180515055913.alk3pau43e3jps3y@esperanza> <1e31235c-f4e3-1046-57c8-741de095e616@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1e31235c-f4e3-1046-57c8-741de095e616@virtuozzo.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 15, 2018 at 11:55:04AM +0300, Kirill Tkhai wrote: > >> @@ -586,8 +586,23 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, > >> continue; > >> > >> ret = do_shrink_slab(&sc, shrinker, priority); > >> - if (ret == SHRINK_EMPTY) > >> - ret = 0; > >> + if (ret == SHRINK_EMPTY) { > >> + clear_bit(i, map->map); > >> + /* > >> + * Pairs with mb in memcg_set_shrinker_bit(): > >> + * > >> + * list_lru_add() shrink_slab_memcg() > >> + * list_add_tail() clear_bit() > >> + * > >> + * set_bit() do_shrink_slab() > >> + */ > > > > Please improve the comment so that it isn't just a diagram. > > Please, say, which comment you want to see here. I want the reader to understand why we need to invoke the shrinker twice if it returns SHRINK_EMPTY. The diagram doesn't really help here IMO. So I'd write Something like this: ret = do_shrink_slab(&sc, shrinker, priority); if (ret == SHRINK_EMPTY) { clear_bit(i, map->map); /* * After the shrinker reported that it had no objects to free, * but before we cleared the corresponding bit in the memcg * shrinker map, a new object might have been added. To make * sure, we have the bit set in this case, we invoke the * shrinker one more time and re-set the bit if it reports that * it is not empty anymore. The memory barrier here pairs with * the barrier in memcg_set_shrinker_bit(): * * list_lru_add() shrink_slab_memcg() * list_add_tail() clear_bit() * * set_bit() do_shrink_slab() */ smp_mb__after_atomic(); ret = do_shrink_slab(&sc, shrinker, priority); if (ret == SHRINK_EMPTY) ret = 0; else memcg_set_shrinker_bit(memcg, nid, i);