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=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 B6780C43461 for ; Sun, 13 Sep 2020 15:27:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 185AF20731 for ; Sun, 13 Sep 2020 15:27:48 +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="OZONTHLY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 185AF20731 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 23EC76B0002; Sun, 13 Sep 2020 11:27:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EE5D6B0037; Sun, 13 Sep 2020 11:27:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 105216B0055; Sun, 13 Sep 2020 11:27:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0100.hostedemail.com [216.40.44.100]) by kanga.kvack.org (Postfix) with ESMTP id EFD476B0002 for ; Sun, 13 Sep 2020 11:27:47 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id AC657181AEF1A for ; Sun, 13 Sep 2020 15:27:47 +0000 (UTC) X-FDA: 77258418174.19.word31_5d0b96a27101 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 88E181AD1B5 for ; Sun, 13 Sep 2020 15:27:47 +0000 (UTC) X-HE-Tag: word31_5d0b96a27101 X-Filterd-Recvd-Size: 4268 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Sun, 13 Sep 2020 15:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=C1bbDqi5VCfzqw76j0WaYj+8YMSHM3OKpSoM0GoYCKo=; b=OZONTHLY9/TgFfO41JQ+xf6am3 GJdQeLzpPTtraP+6usD99lKEXnWfjZkuGOgAo/Cj4cPBjC0sXLpR/6bOD43DcmCv65a+BtJX0DB/E iJj620MXIapmzXo0y5OoRIGq8YjAylAfC2KBLSG8SqqgFvaJoGD2aCJK7bK/CZJXhrNH7gZZwCyq0 ud+9D0y83Gyi7Ng6HsQp6NfE7Qc+y/cF2xnZ9Ilrw0WN2JKzxieVj/i4pyQXRZXSAnnFIGDlnYhNE XVPdPUH0RHEUs5gBqZ3pm4qm/eCgkvV+Sx18YN3Glw8zlK1Uhba6tusVYMJK5NLL3QfI7zbal90lH K/pli+oQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHTuB-0007a9-UV; Sun, 13 Sep 2020 15:27:04 +0000 Date: Sun, 13 Sep 2020 16:27:03 +0100 From: Matthew Wilcox 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, hannes@cmpxchg.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, Andrea Arcangeli Subject: Re: [PATCH v18 06/32] mm/thp: narrow lru locking Message-ID: <20200913152703.GI6583@casper.infradead.org> References: <1598273705-69124-1-git-send-email-alex.shi@linux.alibaba.com> <1598273705-69124-7-git-send-email-alex.shi@linux.alibaba.com> <20200910134923.GR6583@casper.infradead.org> <514f6afa-dbf7-11c5-5431-1d558d2c20c9@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <514f6afa-dbf7-11c5-5431-1d558d2c20c9@linux.alibaba.com> X-Rspamd-Queue-Id: 88E181AD1B5 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable 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 Fri, Sep 11, 2020 at 11:37:50AM +0800, Alex Shi wrote: >=20 >=20 > =E5=9C=A8 2020/9/10 =E4=B8=8B=E5=8D=889:49, Matthew Wilcox =E5=86=99=E9= =81=93: > > On Mon, Aug 24, 2020 at 08:54:39PM +0800, Alex Shi wrote: > >> lru_lock and page cache xa_lock have no reason with current sequence= , > >> put them together isn't necessary. let's narrow the lru locking, but > >> left the local_irq_disable to block interrupt re-entry and statistic= update. > >=20 > > What stats are you talking about here? >=20 > Hi Matthew, >=20 > Thanks for comments! >=20 > like __dec_node_page_state(head, NR_SHMEM_THPS); will have preemptive w= arning... OK, but those stats are guarded by 'if (mapping)', so this patch doesn't produce that warning because we'll have taken the xarray lock and disable= d interrupts. > > How about this patch instead? It occurred to me we already have > > perfectly good infrastructure to track whether or not interrupts are > > already disabled, and so we should use that instead of ensuring that > > interrupts are disabled, or tracking that ourselves. >=20 > So your proposal looks like; > 1, xa_lock_irq(&mapping->i_pages); (optional) > 2, spin_lock_irqsave(&ds_queue->split_queue_lock, flags); > 3, spin_lock_irqsave(&pgdat->lru_lock, flags); >=20 > Is there meaningful for the 2nd and 3rd flags? Yes. We want to avoid doing: if (mapping) spin_lock(&ds_queue->split_queue_lock); else spin_lock_irq(&ds_queue->split_queue_lock); ... if (mapping) spin_unlock(&ds_queue->split_queue_lock); else spin_unlock_irq(&ds_queue->split_queue_lock); Just using _irqsave has the same effect and is easier to reason about. > IIRC, I had a similar proposal as your, the flags used in xa_lock_irqsa= ve(), > but objected by Hugh. I imagine Hugh's objection was that we know it's safe to disable/enable interrupts here because we're in a sleepable context. But for the other two locks, we'd rather not track whether we've already disabled interrupts or not. Maybe you could dig up the email from Hugh? I can't find it.