Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp206890pxa; Fri, 14 Aug 2020 01:37:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRhZSHIyz29Y6PFcGgc96W/IEUJVaE0KGS8FGld7fMf/f+/xJxUfBvzK1pmC/ZUvhkke56 X-Received: by 2002:a17:906:eb4f:: with SMTP id mc15mr1327511ejb.435.1597394221852; Fri, 14 Aug 2020 01:37:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597394221; cv=none; d=google.com; s=arc-20160816; b=PR2u41me0mO6M0QjAmTGm9gDUUnisv3vJStDfObJ3qd5xcQs2wI4oTbmUC13VvOzU1 0xsHfHjMwkus6jBavDwEjkgk4D3x7qQg6AVrsf+VZERqxkjWKnkrVwxicAuX7/ohmpEh ldXNiYmfgbKO5NDHrfQXMvC36BHw3aP13ZKUdebCRs5Bl7IY4rhXAt9K7CBQ5SiETw9p 0OWJWhbX2gWXCe/JAHP/Tiwt0C8N5dUzwwPcaeIzKfyyQqC+CMBk2XxPDJAj/MjH43wO d52hkXtSQLLBRIZahx7cjs0Q6AklSPP9teg+5ZozND0NvFXFU/qW2tjEggCnTla23UXr RkWg== 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=AdqxtBBzE8zkm3kxwd6M5EQuKDKvTyliTVOnv4Gy5lw=; b=uj1umzPLd20P+WhLEB5WfTJfGvlZoRXaZkkGeOfu4+kNCYHVF9JCLXXnO+RcnZHPnn h8TO2ODUC/qlKG3qRBioD4xI3zgYoPZptciCrOOQ7iJqKgGgnukgOBEfYo1wXJWZL20S KeXXRsQhazmOEWIJpengDk03hPicGyi/15B9g+Cl4SjTx/YOTlqxcgGW6LF+7iPpArJU JV2O2bZcV7LXbS8LibRm1ie+zmIjmkAZ8/D8NPAIBVpn83ftYs+xTIezHP8iaHejVqoR KG+qNux2QxDkpi89TizFvof7DMqKLhNrUF/92xVb0+9g4aHufsmIk4yPCusPGlARfP5I 4KPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oqVy0fps; 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 v4si5681615edl.506.2020.08.14.01.36.37; Fri, 14 Aug 2020 01:37:01 -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=oqVy0fps; 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 S1726931AbgHNIfw (ORCPT + 99 others); Fri, 14 Aug 2020 04:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbgHNIfw (ORCPT ); Fri, 14 Aug 2020 04:35:52 -0400 Received: from mail-yb1-xb43.google.com (mail-yb1-xb43.google.com [IPv6:2607:f8b0:4864:20::b43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC32EC061383 for ; Fri, 14 Aug 2020 01:35:50 -0700 (PDT) Received: by mail-yb1-xb43.google.com with SMTP id e14so4820212ybf.4 for ; Fri, 14 Aug 2020 01:35:50 -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=AdqxtBBzE8zkm3kxwd6M5EQuKDKvTyliTVOnv4Gy5lw=; b=oqVy0fpsXt6mcaf8A0SC3B/hbz8tbu1sLp+p2pRxvv8AbXvXwBHIFsfkMCRqNri3GF qJ5LaxL7IMvfVknso37KHelMIw8Dd2z7cxXhdshfuODzyH2Xseg89iJdaKUlQjvHq7Hq lhVM/0EfF59L/acBDsdGpzOFVzg978mH+5YR0Xnus5a+hauEXlwXVyH0k/uzyUQXeOV+ GoD9sItD5ZTLV2cb+jVfv+1qVPtgrDmNyETiLEcVRayEQDHThAdY1wjwZE3Exe3WMAGf B0CMyWrcmpON8PTov2dXTjRTU6wL6B8HVQWcoUhp+BuAHQUBWllyB0qzr6niC+D7+S2F fxHg== 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=AdqxtBBzE8zkm3kxwd6M5EQuKDKvTyliTVOnv4Gy5lw=; b=HjLoSOJTQfwseycxreI59sUFE6mUunqnrzkGCDcqmkpsW7Ae8tIfAI9StYCBdPnyed FlUBUQvrsUcrzegxFoKnDLt5KcE89gC+rJh2gN+b/BopN0Kl5jLyNi7YNhvkQer6byYm ZY/kPFzrYaebs3ulVKwH9L8y3SB6JSUykJ2F7ZmHlQcEGwZcz01v1HSM/gNLvTKCseoe A3hECLbphA8f0g0rEY9x8ErmccbrZKweszKQ4JpsHJ3/8zCekrUGBj9zsdGZ9JcTUy+m Ob0PBod9CEsC99ufdMsnpJk11qGTiz95uB9549mP6kOIbFUJjmNMQIx+Y75XjzCbD7pq AJyw== X-Gm-Message-State: AOAM533P+dHZ0yj/tYZjjMxEBxbPrcw52ztdQN0/M9zdJg+ID25oxj8V vKfwR3igW3WmaucpoFvQhYaBS0wRR9FdVB2MJxD3Hw== X-Received: by 2002:a25:7455:: with SMTP id p82mr2121422ybc.287.1597394149918; Fri, 14 Aug 2020 01:35:49 -0700 (PDT) MIME-Version: 1.0 References: <1597284810-17454-1-git-send-email-chinwen.chang@mediatek.com> <1597284810-17454-3-git-send-email-chinwen.chang@mediatek.com> In-Reply-To: <1597284810-17454-3-git-send-email-chinwen.chang@mediatek.com> From: Michel Lespinasse Date: Fri, 14 Aug 2020 01:35:37 -0700 Message-ID: Subject: Re: [PATCH v2 2/2] mm: proc: smaps_rollup: do not stall write attempts on mmap_lock 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:13 PM Chinwen Chang wrote: > smaps_rollup will try to grab mmap_lock and go through the whole vma > list until it finishes the iterating. When encountering large processes, > the mmap_lock will be held for a longer time, which may block other > write requests like mmap and munmap from progressing smoothly. > > There are upcoming mmap_lock optimizations like range-based locks, but > the lock applied to smaps_rollup would be the coarse type, which doesn't > avoid the occurrence of unpleasant contention. > > To solve aforementioned issue, we add a check which detects whether > anyone wants to grab mmap_lock for write attempts. I think your retry mechanism still doesn't handle all cases. When you get back the mmap lock, the address where you stopped last time could now be in the middle of a vma. I think the consistent thing to do in that case would be to retry scanning from the address you stopped at, even if it's not on a vma boundary anymore. You may have to change smap_gather_stats to support that, though.