Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1190233pxa; Thu, 13 Aug 2020 02:56:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+aZdBADWCHvMUK8h301jwueYG5JPEk1eQsuNmSacsUPW8Jkbg/dQw3cKq6DzlGGqKnTjn X-Received: by 2002:a17:906:5a8a:: with SMTP id l10mr3737815ejq.397.1597312586358; Thu, 13 Aug 2020 02:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597312586; cv=none; d=google.com; s=arc-20160816; b=v4lxrrjjM+TC462aXp0bo51WyuuuSPIoMfJdKOrmBZTQzZi9kY6unONHLP7+Mulhj5 3Uu/FIRJoTYpllHa3DXcHm2ncEXFVJRbf6Yybb5KTFnQ5x2NrKQl0PNppDpOVquD5w00 25/zv+sUGRt6PSwuu742Fy3zpdLslI4JQ0JXP19W9GgeeRwx6hfob0OMI3o7zhYx6YKI I8wIOkP0xekF7cUav5d0JADyRgHQgRrG+gTdlSLGh/24LijBV3nOxx1m9o49yhVM/vRz 9wdYjBEXCnjHMUb3GzXqfbP7Nn0WzFOEPoWAzU+Yrk0AdetLbbkFUx1coC+ape7m1Bcp 1sYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Yul9D5KaapMfO0wSYYumb3nXfH25wAQuTtPB6LytFFQ=; b=uc5xQvrPiyOtWP8HZYXGq3seO3Zsy+e//2ZC8NjLuA33nihY0Q3NDMtRv3NSq40VFa bORzQHfG32C1txlPACcj3TJZbLBUps54E9C7yMy3lCdfXr6wMvIW5LoufsUAZ89DHcyb ghyGvGR2jxBoLuX71fLUI4xeY+ZoP9LKNMLzy8WWEXowfND6fLYXma3OkTNODCEW5y9l Pcq+Uhf6d2CNfoBUMfGew82TEQErTgvEJP53ONwOn7nYzfjgZdwbfg3oNRbz9g5ejD76 /dsxfYWinXX8f8bl+QMDVTEWSeeHI4dTU12HPa7Z5U4Bm4ociAXxEzMyxl4LnX8Wf7F3 mYzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="g4mDUYV/"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l2si1057567eds.451.2020.08.13.02.56.03; Thu, 13 Aug 2020 02:56:26 -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=pass header.i=@google.com header.s=20161025 header.b="g4mDUYV/"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbgHMJxe (ORCPT + 99 others); Thu, 13 Aug 2020 05:53:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726419AbgHMJxe (ORCPT ); Thu, 13 Aug 2020 05:53:34 -0400 Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 086EBC061383 for ; Thu, 13 Aug 2020 02:53:34 -0700 (PDT) Received: by mail-yb1-xb41.google.com with SMTP id q3so2982113ybp.7 for ; Thu, 13 Aug 2020 02:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Yul9D5KaapMfO0wSYYumb3nXfH25wAQuTtPB6LytFFQ=; b=g4mDUYV/kR2xqvMovbB9tOP1UwfQk6O047mQnaEfU/wAgqPu1NK8GhI6gfzcY5gZQ3 kZdFLbxgB7OqRvASEeMmcEe99LPAOZaz1kZskBXb/8XLTVke3a8uOYyXOpCAh4FedTtR 9E7hUlfMGcRn3WfwvWi5YlF/FOSHG3E+wgdpSgj+p9Y2eLtGyRueVDENXxuIaA1s3otY fFOfdc7Cz1qEY35Es+aJJFSnpioiFZWGZk+LMsIWu/gGIUaAk2if4K2HJi4QVVS8cDdU ckMfr+jW5QSRMSVhuiCR8ex32+qd5wmgdgLepZcJIB/BCSs6gIOX0NPYuRcry/7YIAgL JPPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Yul9D5KaapMfO0wSYYumb3nXfH25wAQuTtPB6LytFFQ=; b=tYSVKjhiedHQCNPiw6F/HhiqK6ILeuvTPAyJ/Ngv74UxjvCMw/9j+v/3ccWD6H1UWI 0UI0sAxPdz/FyapEdLGkT07wpkuHCt4Qx9n4mD0lw+fSClpio4weFBu4IViec8/i1RkM udTuNi2AAuAaSGUu8R0l/HjMiNiDwz6nPkMgCaZI0GUj0SFFcMRPK5iiTIGUrflmJtAx 9JWvTXuAuyr8bA3u2JVaf3p/3D/t5Y3iZg3fptrWiX8U7puqJ9lw1J2s8UM7ssi68Ko1 56eDS8k2WKLnQhyhetcpJ5A9ISPJy/6CzJtLe96ci1I+ztTAms+O5yuq5YVfUGFlETu6 cCmw== X-Gm-Message-State: AOAM531uS146DMhGu4kpTZHp4tqOe8RXOlpUXlDUmrpY3B66+tBwfK3o mOmPUkw9wCPJwQNIR3yrBicc2dK9Rk9LWb4PfOjadQ== X-Received: by 2002:a25:ab34:: with SMTP id u49mr5170276ybi.516.1597312412264; Thu, 13 Aug 2020 02:53:32 -0700 (PDT) MIME-Version: 1.0 References: <1597284810-17454-1-git-send-email-chinwen.chang@mediatek.com> In-Reply-To: <1597284810-17454-1-git-send-email-chinwen.chang@mediatek.com> From: Michel Lespinasse Date: Thu, 13 Aug 2020 02:53:20 -0700 Message-ID: Subject: Re: [PATCH v2 0/2] Try to release mmap_lock temporarily in smaps_rollup To: Chinwen Chang Cc: Matthias Brugger , Andrew Morton , Vlastimil Babka , Daniel Jordan , Davidlohr Bueso , Alexey Dobriyan , "Matthew Wilcox (Oracle)" , Jason Gunthorpe , Steven Price , Song Liu , Jimmy Assarsson , Huang Ying , LKML , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-fsdevel@vger.kernel.org, wsd_upstream@mediatek.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 12, 2020 at 7:14 PM Chinwen Chang wrote: > Recently, we have observed some janky issues caused by unpleasantly long > contention on mmap_lock which is held by smaps_rollup when probing large > processes. To address the problem, we let smaps_rollup detect if anyone > wants to acquire mmap_lock for write attempts. If yes, just release the > lock temporarily to ease the contention. > > smaps_rollup is a procfs interface which allows users to summarize the > process's memory usage without the overhead of seq_* calls. Android uses it > to sample the memory usage of various processes to balance its memory pool > sizes. If no one wants to take the lock for write requests, smaps_rollup > with this patch will behave like the original one. > > Although there are on-going mmap_lock optimizations like range-based locks, > the lock applied to smaps_rollup would be the coarse one, which is hard to > avoid the occurrence of aforementioned issues. So the detection and > temporary release for write attempts on mmap_lock in smaps_rollup is still > necessary. I do not mind extending the mmap lock API as needed. However, in the past I have tried adding rwsem_is_contended to mlock(), and later to mm_populate() paths, and IIRC gotten pushback on it both times. I don't feel strongly on this, but would prefer if someone else approved the rwsem_is_contended() use case. Couple related questions, how many VMAs are we looking at here ? Would need_resched() be workable too ? -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies.