Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4626733ybi; Tue, 30 Jul 2019 05:26:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyM4OJA9yLvCCszV9fWaKzvD0foJR4CaVt4Qe5uSm0MZczpLE2hpQHyHnNixjLBZUtZtMlO X-Received: by 2002:a63:7887:: with SMTP id t129mr23623265pgc.309.1564489573312; Tue, 30 Jul 2019 05:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564489573; cv=none; d=google.com; s=arc-20160816; b=jvqofpY1tL7OO+0LaoG1Yp7a8ln+fetPBVpM//TJRyEvrVEoqdR4ayJPZzIwfp6lTb 4F4iVeMTFd2+fBOaaQYSw3ZtIcT8j029t2E4CG0nxeVjZf+uiY8uCaHan7XswDYtie24 pZveMA6rgB/ZQXhCZoS6W/75Q4LyziUH8X51keEJ60KSB0vhQ+OU8IF1tiXFxLeWT3Yb liJLVtZIzHFEYMBHVOhKo2pWOFx2TS/Wu60Cyjlx/0VdZeINJdw486Pdtsq5NEhWwwYe g3eD2QmZEgFeiRtzYKSnxMOsFjww+VZV40LMis50u0Rtj5QjyJUdcG9hFdnS/Zs3qRQD JXQg== 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:dkim-signature; bh=Wpon5LXiMRjWM4VYIexd4NaoumE7zgOXY2Q2zhMR31E=; b=dFIzn1TB8DInzIRW8pj78O36hXuDbehcZXFY5FIZ3p7R7N7RPyac3JDNmtz1wA0wWE POagL6f0/CphJBE9jQqKxCCDs1Z8OpEcssTcUZtCC31eDujCMu0lNKZ3+UbObiPaHmlx uzRITJOL3PYE68JGEcpQ87TE9GuRi7wsehiux7lrfIpwbUrLPeQhW3pVk33mTlYqAkGp 34Pzw/XgUxeCr0+Ly8cm/lVlJbunP49VOvnRY1sP28u8IsCeoaMUA6Chfp2wgaiiRr7m WF0yHnZvyfIYnF70B3SWLJgku7xOQMawHJcH6XZHxsy45t31onqP67mXbD8YiSm9VkJi vlbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=bYOaA1bj; 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 e4si15742654pgh.434.2019.07.30.05.25.59; Tue, 30 Jul 2019 05:26:13 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=bYOaA1bj; 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 S1730538AbfG3MLR (ORCPT + 99 others); Tue, 30 Jul 2019 08:11:17 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:39110 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729204AbfG3MLR (ORCPT ); Tue, 30 Jul 2019 08:11:17 -0400 Received: by mail-pg1-f194.google.com with SMTP id u17so29966357pgi.6 for ; Tue, 30 Jul 2019 05:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Wpon5LXiMRjWM4VYIexd4NaoumE7zgOXY2Q2zhMR31E=; b=bYOaA1bjRco0KHiZUAi1zM5jzjhzBM9TFIVJFCNiCUd9klzlUnSBKKxdDG4ISThyEg dKAvL9lhA4uGT5YSTc3c/AQ7R68uUd7Qh3u1Ib/j9CIUG36TpMQxJJbYXw7vHVZcO59A BczKwzrUBb0l+kBbfjr/G3/FnLYjZdWYP52hSIax7z7O3Giv8C50XnV4a1Vpu+gJS4Xd 8PI7hObtiD+MWvhhPxwZw+For/ajH7QgYSyEkQtIVLp2461/mPALNlafvpkaB1gsbWiP /RDkpdDEAStH+4711XBFhYWtRgR3XN777zbvF4LMwCWK3qOQ3nCovPrhKed6mVA5NYFU K3cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Wpon5LXiMRjWM4VYIexd4NaoumE7zgOXY2Q2zhMR31E=; b=NZGw05Ne2wLf12rBoie5NtH2gK8FupRl1E1Nbv/GFeTsalmW0kRKYvZgy6sDMpzTmE IC5i6O/bMag23h6ZJlHhWcTOyVJbY/wOKiY02YZXe8+lciij/jZm0EwIrlSuraHIxVOM ndiS07uM/evR7R1bPESUbSlgRV5Lr/Okh8221gLuL/COumy4TIkw3MgB11wOLPeGSifl 3lnmU1kifHXI4X0LzhaWXArBByBscg/OPyvpHTKkKsz5HGmJCSr5aSYJuUEB3cqObLDX gzNKFUFSQ2Af0vN1xju2KoaT0h/oinrcqGf8hmz+Y0NXap+FGu6jd04DTWBgKXz7fX5t QjnA== X-Gm-Message-State: APjAAAWsDR4UIHyP16csB5GHeVY6E/bzauwF1XlOCorOhmNnAYbTTzvg ywUViR/aa1XUApdxKdwERIo= X-Received: by 2002:a17:90a:2488:: with SMTP id i8mr114501776pje.123.1564488676117; Tue, 30 Jul 2019 05:11:16 -0700 (PDT) Received: from google.com ([2401:fa00:d:0:98f1:8b3d:1f37:3e8]) by smtp.gmail.com with ESMTPSA id a5sm56153980pjv.21.2019.07.30.05.11.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 30 Jul 2019 05:11:14 -0700 (PDT) Date: Tue, 30 Jul 2019 21:11:10 +0900 From: Minchan Kim To: Michal Hocko 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: <20190730121110.GA184615@google.com> References: <20190729071037.241581-1-minchan@kernel.org> <20190729074523.GC9330@dhcp22.suse.cz> <20190729082052.GA258885@google.com> <20190729083515.GD9330@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190729083515.GD9330@dhcp22.suse.cz> 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, Jul 29, 2019 at 10:35:15AM +0200, Michal Hocko wrote: > On Mon 29-07-19 17:20:52, Minchan Kim wrote: > > On Mon, Jul 29, 2019 at 09:45:23AM +0200, Michal Hocko wrote: > > > 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? > > > > Miguel confirmed there is no such big latency without mark_page_accessed > > in zap_pte_range so I guess it's the contention of LRU lock as well as > > heavy activate_page overhead which is not trivial, either. > > Please give us more details ideally with some numbers. I had a time to benchmark it via adding some trace_printk hooks between pte_offset_map_lock and pte_unmap_unlock in zap_pte_range. The testing device is 2018 premium mobile device. I can get 2ms delay rather easily to release 2M(ie, 512 pages) when the task runs on little core even though it doesn't have any IPI and LRU lock contention. It's already too heavy. If I remove activate_page, 35-40% overhead of zap_pte_range is gone so most of overhead(about 0.7ms) comes from activate_page via mark_page_accessed. Thus, if there are LRU contention, that 0.7ms could accumulate up to several ms.