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=-6.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 02268C00A89 for ; Mon, 2 Nov 2020 15:22:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A46AF22226 for ; Mon, 2 Nov 2020 15:22:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="bAkYwaoc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A46AF22226 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 456176B0071; Mon, 2 Nov 2020 10:22:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3DDA26B007B; Mon, 2 Nov 2020 10:22:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A62C6B007D; Mon, 2 Nov 2020 10:22:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id E9C2E6B0071 for ; Mon, 2 Nov 2020 10:22:32 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7738E3629 for ; Mon, 2 Nov 2020 15:22:32 +0000 (UTC) X-FDA: 77439844944.28.stove44_3a13c53272b1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 4BAF66C2D for ; Mon, 2 Nov 2020 15:22:32 +0000 (UTC) X-HE-Tag: stove44_3a13c53272b1 X-Filterd-Recvd-Size: 4649 Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Mon, 2 Nov 2020 15:22:31 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id m65so9360298qte.11 for ; Mon, 02 Nov 2020 07:22:31 -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=PZfLygvPchTUSgGMmFZPk8zJRPc7y3a0+u5vclYWa+g=; b=bAkYwaocuGeef7r/WOYoDUSYpYjQDgRDpirAbBQA4pgs0hzQ0GiYmrYxa29dxnVHRF WxZ+s5OiKNjfk7VuV+xQNYKlAGD4juHOKsM0ZetbZkYA9t1Tbh1k2izLHb7ERccLcgHm GCCABAf8ThtuwtqKtEcG6HvFonuEEIP0GHWjilwMZYs78mM8ItctpBi0UBxTd5qcNaAs QdZ7tgIjuj20hncEA5VgCavYzeW6I9e9gAOIUgoiUtVovsIhhie+0DjaKZnVF0kJxI0J Jf02bfDygNUlJuqZ865wjaIfGmJK7DpfTtDj0KZDfr56i5YflC13w1YJT5czGz7ws46t JTtQ== 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=PZfLygvPchTUSgGMmFZPk8zJRPc7y3a0+u5vclYWa+g=; b=kXYYZWM9mTnvkp0w05Y/sVDKIaMgunW+ZxHtaAZPXaq8m8h71o/fvWpyxMCvSSlhuh 06avXPoeyomRJhW9/ZfcQkwZTW8nNU/k07VhPShwLr672DubLR35gRt1zlmmN8uEqESX zyi3hwnWnfXSiIRkk7iWX6d7sjpCibiWb1vi5IZOXGhvVoXTcmXLI4W2O7r2YdmNVlbQ UE5w9hkysQwiNBXjf7YGoKAY9jbCUV7746UG8owkQiQAEUd2cvDYxDGv8opOJnPnDwhP CFHLdsLOMDftPw8TWB9IEOMvQJ3t4IhnugN6868DztuuJQyL2V6CbvF7M1Acd/WTQq4l gphA== X-Gm-Message-State: AOAM5318EmR6Zi67HFLg0HNTSO/uRxx3YNf2VEEwwOd+TLdZ0B2V0CyT 0myPLvnPZ2p7GF1257gcZdmhCA== X-Google-Smtp-Source: ABdhPJxSwd5B22hT5eiV6LBd9rt7/VanBXU8KpL4jRhTH+94Q2JIMRQvuMsiEz1tN3erRApM/xKQzA== X-Received: by 2002:aed:2941:: with SMTP id s59mr14633752qtd.387.1604330550876; Mon, 02 Nov 2020 07:22:30 -0800 (PST) Received: from localhost ([2620:10d:c091:480::1:2f6e]) by smtp.gmail.com with ESMTPSA id p2sm3861044qkk.34.2020.11.02.07.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 07:22:30 -0800 (PST) Date: Mon, 2 Nov 2020 10:20:45 -0500 From: Johannes Weiner To: Alex Shi Cc: akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, willy@infradead.org, lkp@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, shakeelb@google.com, iamjoonsoo.kim@lge.com, richard.weiyang@gmail.com, kirill@shutemov.name, alexander.duyck@gmail.com, rong.a.chen@intel.com, mhocko@suse.com, vdavydov.dev@gmail.com, shy828301@gmail.com Subject: Re: [PATCH v20 17/20] mm/swap.c: serialize memcg changes in pagevec_lru_move_fn Message-ID: <20201102152045.GJ724984@cmpxchg.org> References: <1603968305-8026-1-git-send-email-alex.shi@linux.alibaba.com> <1603968305-8026-18-git-send-email-alex.shi@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1603968305-8026-18-git-send-email-alex.shi@linux.alibaba.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 Thu, Oct 29, 2020 at 06:45:02PM +0800, Alex Shi wrote: > Hugh Dickins' found a memcg change bug on original version: > If we want to change the pgdat->lru_lock to memcg's lruvec lock, we have > to serialize mem_cgroup_move_account during pagevec_lru_move_fn. The > possible bad scenario would like: > > cpu 0 cpu 1 > lruvec = mem_cgroup_page_lruvec() > if (!isolate_lru_page()) > mem_cgroup_move_account > > spin_lock_irqsave(&lruvec->lru_lock <== wrong lock. > > So we need TestClearPageLRU to block isolate_lru_page(), that serializes > the memcg change. and then removing the PageLRU check in move_fn callee > as the consequence. > > __pagevec_lru_add_fn() is different from the others, because the pages > it deals with are, by definition, not yet on the lru. TestClearPageLRU > is not needed and would not work, so __pagevec_lru_add() goes its own > way. > > Reported-by: Hugh Dickins > Signed-off-by: Alex Shi > Acked-by: Hugh Dickins > Cc: Andrew Morton > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org Acked-by: Johannes Weiner