From patchwork Fri Nov 5 20:37:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12605483 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 DF0B7C433EF for ; Fri, 5 Nov 2021 20:37:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9882860174 for ; Fri, 5 Nov 2021 20:37:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9882860174 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 39DFC940038; Fri, 5 Nov 2021 16:37:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D8F4940007; Fri, 5 Nov 2021 16:37:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 179D2940038; Fri, 5 Nov 2021 16:37:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0180.hostedemail.com [216.40.44.180]) by kanga.kvack.org (Postfix) with ESMTP id 0353D940007 for ; Fri, 5 Nov 2021 16:37:49 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BA6A77798B for ; Fri, 5 Nov 2021 20:37:48 +0000 (UTC) X-FDA: 78776037816.29.A85F23F Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf10.hostedemail.com (Postfix) with ESMTP id F37C160019A7 for ; Fri, 5 Nov 2021 20:37:36 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 8343B61252; Fri, 5 Nov 2021 20:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1636144667; bh=I3HMw03PdXao4xhAgGi9zClkcaC8ZMkFxxofAO2HuRM=; h=Date:From:To:Subject:In-Reply-To:From; b=mTTLJT5F0Y5SX9PJeCHjp5vC9WYuqPFed4A40PljPf0nfBRaIyP297c+VGB5eogFB C6ma27BZMh90v39YG08LCSg4Ca+K88mPunOEgZBXBBZvMEQ5lCHZvRx/zNiMKn4BrR igE4aXNtZaLW3CExg4cEXDYN2OyTmG3sOdwc/cjw= Date: Fri, 05 Nov 2021 13:37:47 -0700 From: Andrew Morton To: akpm@linux-foundation.org, guro@fb.com, hannes@cmpxchg.org, linux-mm@kvack.org, mhocko@kernel.org, mm-commits@vger.kernel.org, shakeelb@google.com, songmuchun@bytedance.com, torvalds@linux-foundation.org, willy@infradead.org Subject: [patch 060/262] mm: list_lru: remove holding lru lock Message-ID: <20211105203747.qUrOzAFsm%akpm@linux-foundation.org> In-Reply-To: <20211105133408.cccbb98b71a77d5e8430aba1@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: F37C160019A7 X-Stat-Signature: 5pfk1iunp17ntz5574foyeqr8aae4fzw Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=mTTLJT5F; dmarc=none; spf=pass (imf10.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1636144656-435388 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: From: Muchun Song Subject: mm: list_lru: remove holding lru lock 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 to avoid taking rcu lock. So just remove holding lock. Link: https://lkml.kernel.org/r/20211025124534.56345-1-songmuchun@bytedance.com Signed-off-by: Muchun Song Cc: Johannes Weiner Cc: Matthew Wilcox (Oracle) Cc: Michal Hocko Cc: Roman Gushchin Cc: Shakeel Butt Signed-off-by: Andrew Morton --- mm/list_lru.c | 11 ----------- 1 file changed, 11 deletions(-) --- a/mm/list_lru.c~mm-list_lru-remove-holding-lru-lock +++ a/mm/list_lru.c @@ -398,18 +398,7 @@ static int memcg_update_list_lru_node(st } 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; }