Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5191870ybi; Tue, 30 Jul 2019 15:50:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlYedLqTceS2+qPROHpPMxPr+5okES47YEzHQePoJOcsHXQKbGk5v9b/8sUdTuSOKNeeNU X-Received: by 2002:a17:902:543:: with SMTP id 61mr117036659plf.20.1564527008150; Tue, 30 Jul 2019 15:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564527008; cv=none; d=google.com; s=arc-20160816; b=mDeI+dK4PKawn0UVMiPPQa6aeuPLHSvoc1agDunlnEgvDfQQr5g6Q4Hr7rjn+v30OT bdUDuKUBLxxMaQSTkB0pEpPdo/bYFDnWQiNbpK/y3QkPMTTlFqKNLMWyk9erYnsMR6TC UbO13c+rTb88hhgyjG65Fb4+74LUJ4MCbpcK07kaRRSAKe4e8bl9nH4qdu/GLW/sz3rn HQJT/jqr8+WleAGg0sIwa39DKjS6cshx0mGbiiP/M8LEpIsMneiZwHUAJ9X/3ESFGnrs gFXzMcaSo7OllObQMfW66DpMKdaFrLoO7B/Nfohz/l9SgE+2fU5wX25Q0CI643qkhc2/ E2Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=XkJBF2doekJ4Iv+TVOYQJyouKel1/VeuFiZWcdh1rQw=; b=uOn8zIgNqhVHr4/csq2pJAP7rIhm+J1MTHjl4gj/14aQx5ZJVtumNJo7wTW44NCilk IxGGWZfQvmfTupSFe7+xVBS624OocF6Lstz1aOK2yHsGUH4PFvk2sasLA2az4v8SGtHf ZV5HUZQqKehY4RQiQqBio6Ojk3SA11Fw5ccQH4poNLpwqtdp1sDk0dmZAuChul3sOFBY g6gVg9yhiK8MUMDkBt1O60Fi8SrJ5AT36ysWoBbLxRjrIxWjJm3IqATU2RTFSpX/cdyv TdENNugmHbnQJ3X+Z262FdQk9urja1o7i0sB3kfC463UPxwhuadIoABhOeuk3doGlJXy zDHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3si31617961pls.176.2019.07.30.15.49.51; Tue, 30 Jul 2019 15:50:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726318AbfG3TmM (ORCPT + 99 others); Tue, 30 Jul 2019 15:42:12 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45666 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726216AbfG3TmM (ORCPT ); Tue, 30 Jul 2019 15:42:12 -0400 Received: from X1 (unknown [76.191.170.112]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 878213336; Tue, 30 Jul 2019 19:42:09 +0000 (UTC) Date: Tue, 30 Jul 2019 12:42:07 -0700 From: Andrew Morton To: Minchan Kim Cc: Michal Hocko , LKML , linux-mm , Miguel de Dios , Wei Wang , Johannes Weiner , Mel Gorman Subject: Re: [PATCH] mm: release the spinlock on zap_pte_range Message-Id: <20190730124207.da70f92f19dc021bf052abd0@linux-foundation.org> In-Reply-To: <20190729082052.GA258885@google.com> References: <20190729071037.241581-1-minchan@kernel.org> <20190729074523.GC9330@dhcp22.suse.cz> <20190729082052.GA258885@google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 29 Jul 2019 17:20:52 +0900 Minchan Kim wrote: > > > @@ -1022,7 +1023,16 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, > > > flush_tlb_batched_pending(mm); > > > arch_enter_lazy_mmu_mode(); > > > do { > > > - pte_t ptent = *pte; > > > + pte_t ptent; > > > + > > > + if (progress >= 32) { > > > + progress = 0; > > > + if (need_resched()) > > > + break; > > > + } > > > + progress += 8; > > > > Why 8? > > Just copied from copy_pte_range. copy_pte_range() does if (pte_none(*src_pte)) { progress++; continue; } entry.val = copy_one_pte(dst_mm, src_mm, dst_pte, src_pte, vma, addr, rss); if (entry.val) break; progress += 8; which appears to be an attempt to balance the cost of copy_one_pte() against the cost of not calling copy_one_pte(). Your code doesn't do this balancing and hence can be simpler. It all seems a bit overdesigned. need_resched() is cheap. It's possibly a mistake to check need_resched() on *every* loop because some crazy scheduling load might livelock us. But surely it would be enough to do something like if (progress++ && need_resched()) { progress = 0; } and leave it at that?