Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1589780pxk; Sun, 13 Sep 2020 08:28:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4+1l5VEPYb9lKGU6qnTWEiPZeejUzgIIp/gSHDb8HVyjp7jF1B1lCKsISOqRCXK5BMHoq X-Received: by 2002:a50:cd5e:: with SMTP id d30mr12800792edj.190.1600010934000; Sun, 13 Sep 2020 08:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600010933; cv=none; d=google.com; s=arc-20160816; b=q48SFtxrMFFoBdd7AfWhgA8TEPhz8y4aglrHODd2qYt3f9lUAxE9z0LMVfejVV09qs ylc5QbrC1foMErlZS561AYNDY78kE/MOqyBe9hTWvW2hJGCTcag7XqTuNQ4OY4uH8eRx 6IpU265H/fcRYxscN+3wRowZZbcpb6E8TeN5abvX4BcRJI10fQFBz642knX0X5esJR/v ZHSRN1s3ES2Zn4C0b3to+nndTNRKVs3Sw9yMb67QV8zaOlGpESKpIDdZtkKFJgsOuGSA PUDYK9petYBp47r+AgpTHy34RTxbEKedk5Op7JMbgiYkNVMvjU+w6e7qaEArE2dETS7X 1+hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=C1bbDqi5VCfzqw76j0WaYj+8YMSHM3OKpSoM0GoYCKo=; b=XF3pG891WOFzhcYp948eQUHvAODC3NPGlzId1/jJB1PPoV6VxDB/lyUbS28l8lWOCJ hGSuUfjCtzubNjNags1HzBEYc+Qr35g2ixdDkW/aQXwnOTgVXDfsJf7Q/doeqdpH6RWd k6SrdGARvFdllAwQv1b2dU1fp/Ulo2hvkeIZ7KABVaoZCmZflJZr2JrNhv0IpoO2MN3G anUBaPE9xbkmOloNsSJnZHln6fqLDW5FDur1SaYFCB0Cou6oR6XtdA6+JcAFjM4OA2+a AjptxIG7BlyjMpNATY/OJLBUdfNcuByN6V0QOBi/FjfjjdFZ6EsHqfICyWJuQ9wbTXAB U7RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=OZONTHLY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q3si5341353edg.429.2020.09.13.08.28.29; Sun, 13 Sep 2020 08:28:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=OZONTHLY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725943AbgIMP1u (ORCPT + 99 others); Sun, 13 Sep 2020 11:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbgIMP1t (ORCPT ); Sun, 13 Sep 2020 11:27:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 020C5C06174A; Sun, 13 Sep 2020 08:27:48 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit In-Reply-To: <514f6afa-dbf7-11c5-5431-1d558d2c20c9@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 11, 2020 at 11:37:50AM +0800, Alex Shi wrote: > > > 在 2020/9/10 下午9:49, Matthew Wilcox 写道: > > 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. > > > > What stats are you talking about here? > > Hi Matthew, > > Thanks for comments! > > like __dec_node_page_state(head, NR_SHMEM_THPS); will have preemptive warning... 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 disabled 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. > > 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); > > 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_irqsave(), > 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.