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=-2.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 AD8A9C43331 for ; Tue, 12 Nov 2019 14:36:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7223C20674 for ; Tue, 12 Nov 2019 14:36:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="cG9StvAy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7223C20674 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0BA486B0007; Tue, 12 Nov 2019 09:36:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 06B296B0008; Tue, 12 Nov 2019 09:36:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC2C36B000C; Tue, 12 Nov 2019 09:36:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id D77AA6B0007 for ; Tue, 12 Nov 2019 09:36:31 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 8EDAF40C3 for ; Tue, 12 Nov 2019 14:36:31 +0000 (UTC) X-FDA: 76147876182.03.bit98_38eeded489543 X-HE-Tag: bit98_38eeded489543 X-Filterd-Recvd-Size: 3744 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Nov 2019 14:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=briRr4penNer7yCYr1Mz18mrOJd7t7axFykNNy0cVvo=; b=cG9StvAycZrwX1J4Ja3+Z6jYV tcfKr2cRY7ZGVp+FomV0iqbUppusSjTls6D/m9+RTPA3fK+wP06Cd6zk+K/aI5h1y0JtPJz7SWyG+ xXqea+So7oSWXdyBKTz6/m/JsvAo/DBs08+WXR1+fXt3nzcGd/YIt21ot1wGQo+2YyiDITwzOCcse Ntkql+CKhptFoHDmTuYq836CaADrp8rPq274uBAd6AjXxdQRaK5z3VjdFXuf2IV+suIqodllLvMGW W+6ocEpOYON4EMjkJv4J6ne+duU0fMl4xIPs8F2ggb1NempYKzKSFUnTZggA7BFuq8ufDJO+KQJmd 6/ozJLeRA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iUXHN-0003KB-1E; Tue, 12 Nov 2019 14:36:25 +0000 Date: Tue, 12 Nov 2019 06:36:24 -0800 From: Matthew Wilcox To: Alex Shi Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, yang.shi@linux.alibaba.com, Johannes Weiner , Michal Hocko , Vladimir Davydov , Roman Gushchin , Shakeel Butt , Chris Down , Thomas Gleixner , Vlastimil Babka , Andrey Ryabinin , swkhack , "Potyra, Stefan" , Jason Gunthorpe , Mauro Carvalho Chehab , Peng Fan , Nikolay Borisov , Ira Weiny , Kirill Tkhai , Yafang Shao Subject: Re: [PATCH v2 4/8] mm/lru: only change the lru_lock iff page's lruvec is different Message-ID: <20191112143624.GA7934@bombadil.infradead.org> References: <1573567588-47048-1-git-send-email-alex.shi@linux.alibaba.com> <1573567588-47048-5-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: <1573567588-47048-5-git-send-email-alex.shi@linux.alibaba.com> User-Agent: Mutt/1.12.1 (2019-06-15) 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 Tue, Nov 12, 2019 at 10:06:24PM +0800, Alex Shi wrote: > +/* Don't lock again iff page's lruvec locked */ > +static inline struct lruvec *relock_page_lruvec_irq(struct page *page, > + struct lruvec *locked_lruvec) > +{ > + struct pglist_data *pgdat = page_pgdat(page); > + struct lruvec *lruvec; > + > + rcu_read_lock(); > + lruvec = mem_cgroup_page_lruvec(page, pgdat); > + > + if (locked_lruvec == lruvec) { > + rcu_read_unlock(); > + return lruvec; > + } > + rcu_read_unlock(); Why not simply: rcu_read_lock(); lruvec = mem_cgroup_page_lruvec(page, pgdat); rcu_read_unlock(); if (locked_lruvec == lruvec) return lruvec; Also, why are you bothering to re-enable interrupts here? Surely if you're holding lock A with interrupts disabled , you can just drop lock A, acquire lock B and leave the interrupts alone. That way you only need one of this variety of function, and not the separate irq/irqsave variants.