Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3153920ybi; Mon, 29 Jul 2019 01:50:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqztK85r5VtzRP8BjDdsoqtcASoACoUX9+9VAkJwEcwaOjhArayT9LBUiqEGmwLLbdmjSRkG X-Received: by 2002:a17:90a:bb01:: with SMTP id u1mr108769378pjr.92.1564390259245; Mon, 29 Jul 2019 01:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564390259; cv=none; d=google.com; s=arc-20160816; b=Gp0v6+GJn0ExqWyXuBz6V3eZ6MxLmScK7hW4+lAsIyPq1mBqkE55mG7MZyxCA68QU2 aWzhnGVvAfFjGpjmc+NJTcq29ndE5F5r0wnPVmla7N/YxshSB4IANU4YJLNNmTLtLwSb kwd3/UAkc0iojb27eEROEOwVioXJSDi/l1H2wVS16QeRuhImpCpyrh4eBJAvxpJ+i7uV sb10xSC5Dnq/2Te5AJftZwd6RgR8v/i4r1oR3s21hb6boZZzB4yQ6KLx5Sc2OW37ejwt UnrSEi8iFkHTcxYH8+IsOcVAA9XbI3L6qe1bBUiWVTLO6MCW1c+NnO79RqJ7grTd802N G/Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=yqSQZl5BR1RkSKHgIy75PKBcAUe+/8sHe4TA3mojtkU=; b=wnWCSWYq7P3e1f1Po+xeCrDcbEmWDmjFbgAoYfCUNDa4MX+fWDcwcY99i+w8zq07g6 24fs189b2zaCURFTT415+zI7OHV82RtX/UpjT45b765a3hQmxyng7H1BYZnrHW5uy5es aOnAzQ9Lz+Ey2KsakLJY9Pe7BpHXsH+Xm4Ij1cOqx1OKHSY7ceexu0qJepug6kG9QRxX BomDViBWRzKEBTNRZVOUuK9RNLagnZF+g1xLdo2cOLXWmUllvYGCntNbNoXdjuRieWXc xUKRZJr3oKGcHRNtYg7HCIy/JEDkMYSuisV2PSkDW27ph3bY0R8WZj3Dk7ElMRFvB/mH 9yJg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1si14198778pgd.443.2019.07.29.01.50.43; Mon, 29 Jul 2019 01:50:59 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727081AbfG2HpZ (ORCPT + 99 others); Mon, 29 Jul 2019 03:45:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:35986 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726862AbfG2HpZ (ORCPT ); Mon, 29 Jul 2019 03:45:25 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7FC2CAE5E; Mon, 29 Jul 2019 07:45:24 +0000 (UTC) Date: Mon, 29 Jul 2019 09:45:23 +0200 From: Michal Hocko To: Minchan Kim Cc: Andrew Morton , 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: <20190729074523.GC9330@dhcp22.suse.cz> References: <20190729071037.241581-1-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190729071037.241581-1-minchan@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 29-07-19 16:10:37, Minchan Kim wrote: > In our testing(carmera recording), Miguel and Wei found unmap_page_range > takes above 6ms with preemption disabled easily. When I see that, the > reason is it holds page table spinlock during entire 512 page operation > in a PMD. 6.2ms is never trivial for user experince if RT task couldn't > run in the time because it could make frame drop or glitch audio problem. Where is the time spent during the tear down? 512 pages doesn't sound like a lot to tear down. Is it the TLB flushing? > This patch adds preemption point like coyp_pte_range. > > Reported-by: Miguel de Dios > Reported-by: Wei Wang > Cc: Michal Hocko > Cc: Johannes Weiner > Cc: Mel Gorman > Signed-off-by: Minchan Kim > --- > mm/memory.c | 19 ++++++++++++++++--- > 1 file changed, 16 insertions(+), 3 deletions(-) > > diff --git a/mm/memory.c b/mm/memory.c > index 2e796372927fd..bc3e0c5e4f89b 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -1007,6 +1007,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, > struct zap_details *details) > { > struct mm_struct *mm = tlb->mm; > + int progress = 0; > int force_flush = 0; > int rss[NR_MM_COUNTERS]; > spinlock_t *ptl; > @@ -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? > + > + ptent = *pte; > if (pte_none(ptent)) > continue; > > @@ -1123,8 +1133,11 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, > if (force_flush) { > force_flush = 0; > tlb_flush_mmu(tlb); > - if (addr != end) > - goto again; > + } > + > + if (addr != end) { > + progress = 0; > + goto again; > } > > return addr; > -- > 2.22.0.709.g102302147b-goog -- Michal Hocko SUSE Labs