From patchwork Mon Oct 25 12:45:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12581763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F570C433FE for ; Mon, 25 Oct 2021 12:45:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C22BF60F02 for ; Mon, 25 Oct 2021 12:45:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C22BF60F02 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0B1D36B006C; Mon, 25 Oct 2021 08:45:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0623B6B0072; Mon, 25 Oct 2021 08:45:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6C11940007; Mon, 25 Oct 2021 08:45:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0133.hostedemail.com [216.40.44.133]) by kanga.kvack.org (Postfix) with ESMTP id D99986B006C for ; Mon, 25 Oct 2021 08:45:49 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 967E93015D for ; Mon, 25 Oct 2021 12:45:49 +0000 (UTC) X-FDA: 78734931618.30.0AAE089 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf05.hostedemail.com (Postfix) with ESMTP id DEBB75085CCB for ; Mon, 25 Oct 2021 12:45:39 +0000 (UTC) Received: by mail-pf1-f172.google.com with SMTP id m14so10632107pfc.9 for ; Mon, 25 Oct 2021 05:45:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qVU4cYq6gzQiQmKsTxCHNQ+nSpf6GAnmjdUQN6QjAew=; b=vzztuKVTgZoX81QIwkLGvlv1WgsYk0QmRVnH5mLc/5u2Kr1spSR5z9I27xdVDIiXG3 fNT6vfvu38X3YdXuZxrfJIy/UgvgnGAx4vyVvHX6FzJYWxMRKuWPNgW7wDjJM+IB5EY7 amkbmS55Z/th6v36lrRwWBP7437jUEAjxdRvO/d6qxli9SqrkYlmUyr+GPkvP7Ov55k2 DRePjp3kTJSpPbSF5eQ7RhbotrLXJj1FLQ2Ewukqg56LFX2vobFYokGqmdXLm+sPTmg9 SI6pgcdVauAgoRMocl3vJjcuasuH0v3UckttIpTlIQY7s6pDqNiHPEN6vn8byRLf191m tPLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qVU4cYq6gzQiQmKsTxCHNQ+nSpf6GAnmjdUQN6QjAew=; b=gN88a3FH0DyMaoMziXwSO1D27LU7Ei0MlF8JB86Ml/vJCAc0fbBy3aaychXzbZATyi R7LkLfsFuSzlYOsLiLg4dwvWiu3zgFg2bSzIiKA2c5XvpvRG2a6lh0Md8lK2vcfVu8YM 9YMF3DW6vWOZ01KU2znOFTsD1R1aPEnZ5PJ9i3e66R4EM/AXkaa/+EU4RdVsrrM/oDKX ahmc4oPkxxQQaSarYoCRBlq9JtL50Mn4f2FkMxiTShoWxW1n3Yrwg8CwEM4mrndplWxN CqiDNq4oFrHRfGbCLlZ/IOFUvCfYPeqtFqS330o+9NIYGlnBnt/ljtjA/srT9wnXZykF rc/g== X-Gm-Message-State: AOAM533ail+TP0i0V7AOA8BB7XsQdGrcjKjmA9cY7x1kHNgMqylmQHl4 XAVErXgbBWEFNEEH9iSWz+E4Gg== X-Google-Smtp-Source: ABdhPJyvC+6RSQyWZedPqX9VfAvhYfgRoJTLWPSeHwugj/drfD5CHD3XgoZIM3/t9zh9inDlGRWvvg== X-Received: by 2002:a62:e315:0:b0:47b:f629:6b48 with SMTP id g21-20020a62e315000000b0047bf6296b48mr3910093pfh.72.1635165948112; Mon, 25 Oct 2021 05:45:48 -0700 (PDT) Received: from localhost.localdomain ([61.120.150.70]) by smtp.gmail.com with ESMTPSA id w1sm6268989pjd.1.2021.10.25.05.45.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Oct 2021 05:45:47 -0700 (PDT) From: Muchun Song To: akpm@linux-foundation.org, mhocko@kernel.org, shakeelb@google.com, willy@infradead.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song Subject: [PATCH] mm: list_lru: remove holding lru lock Date: Mon, 25 Oct 2021 20:45:34 +0800 Message-Id: <20211025124534.56345-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: DEBB75085CCB X-Stat-Signature: yuhbmcgs4ce5z88m6wxfqpqj6qftewsd Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=vzztuKVT; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-HE-Tag: 1635165939-461164 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Since commit e5bc3af7734f ("rcu: Consolidate PREEMPT and !PREEMPT synchronize_rcu()"), the critical section of spin lock can serve as an RCU read-side critical section which already allows readers that hold nlru->lock avoid taking rcu lock. So just to remove holding lock. Signed-off-by: Muchun Song --- mm/list_lru.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/mm/list_lru.c b/mm/list_lru.c index 2bba1cd68bb3..7572f8e70b86 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -401,18 +401,7 @@ static int memcg_update_list_lru_node(struct list_lru_node *nlru, } memcpy(&new->lru, &old->lru, flex_array_size(new, lru, old_size)); - - /* - * The locking below allows readers that hold nlru->lock avoid taking - * rcu_read_lock (see list_lru_from_memcg_idx). - * - * Since list_lru_{add,del} may be called under an IRQ-safe lock, - * we have to use IRQ-safe primitives here to avoid deadlock. - */ - spin_lock_irq(&nlru->lock); rcu_assign_pointer(nlru->memcg_lrus, new); - spin_unlock_irq(&nlru->lock); - kvfree_rcu(old, rcu); return 0; }