From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7FAAC433DF for ; Fri, 14 Aug 2020 08:30:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A96922074D for ; Fri, 14 Aug 2020 08:30:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="a8EXI30E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726778AbgHNIaQ (ORCPT ); Fri, 14 Aug 2020 04:30:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbgHNIaP (ORCPT ); Fri, 14 Aug 2020 04:30:15 -0400 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F28E7C061383 for ; Fri, 14 Aug 2020 01:30:14 -0700 (PDT) Received: by mail-yb1-xb42.google.com with SMTP id c9so4808152ybq.1 for ; Fri, 14 Aug 2020 01:30:14 -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=3FTYvzqtwTFg32oQ2R1iT/fxQYwIO5aEnRMfUKVR7Oc=; b=a8EXI30EnDIPpIpx03Sd32eIfrso3BfcxnHyuAmDr5hmLTex8csYsnA9uZ316d8+bV sOEB/63/jWXUQXNPxzlvTziNsLhCzV+LYdqyR66PA/ZKL9aedLGB3m7E4J7PJ96iMNP1 HkdlGmEzCWqRKidgDrvMNP43EbLGV/cRtR73DUUrI0yxZ05fIi5y0fZQtvuqF76mORow zHCXH/esL0lg5ebyMvZHR4aV3OCvpJAPEMnkf656Epo4coILnvz6InECDbGlBQGQHcM0 YlurOpy3r0mZ0QR5hMkDdcvD/SLUmXa1Naesw9cyAoE6/0caKGpBdG4cUvKyjsTkjI+M J5lQ== 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=3FTYvzqtwTFg32oQ2R1iT/fxQYwIO5aEnRMfUKVR7Oc=; b=HE37sdWhOpMeg+Kb5RXRN2v9IfWM4vggLXnh3+7NO6az5x/LBvfxCH6oP4yt9zsY2Y O9rRxfUV1BpfwU3CWzFFIKbRJzr84rzoeaFxUlrlJLulnybe6G/9j45G16asgZS4zVGr O64mkR8ryhNHGWwCnwuC52G4U7hvaTt8S7IIyTHISUnFcy475UsnKpnrxcy+QkMGgzvx oF3GtWJzkiXeDdt0/0KWD+jJfhMyN3TTcaVVMx7FJLHXec4reQOXbtL806t0JkzV/4Qd TmQfRIOch0dhBnzTMvxA24XGQwx2F75zw8AlmKifaIqd/UbOXMkHd8hrlnZobj+ntVFL pPuw== X-Gm-Message-State: AOAM533xWxombIg9kyEZ+IXwdoY/7EotfBDmGhAP8EbZI8E8xdYzl55X L4xG92q7cRrRO2cnJrWeOi2poVCVT6403YF37vHFcA== X-Google-Smtp-Source: ABdhPJw13pPX/3kPqJmeuWDN2VsAFdhKvqiSsbN8Cuj1qsFtz1LjVZiTxa/qFhrVFcgAEIezPtI+eYfXKR4LKmD5VnE= X-Received: by 2002:a25:e684:: with SMTP id d126mr2335998ybh.332.1597393813820; Fri, 14 Aug 2020 01:30:13 -0700 (PDT) MIME-Version: 1.0 References: <1597284810-17454-1-git-send-email-chinwen.chang@mediatek.com> <1597335088.32469.55.camel@mtkswgap22> In-Reply-To: <1597335088.32469.55.camel@mtkswgap22> From: Michel Lespinasse Date: Fri, 14 Aug 2020 01:29:59 -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 Thu, Aug 13, 2020 at 9:11 AM Chinwen Chang wrote: > On Thu, 2020-08-13 at 02:53 -0700, Michel Lespinasse wrote: > > 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. > > > Hi Michel, > > Thank you for your kind feedback. > > In my opinion, the difference between the case in smaps_rollup and the > one in your example is that, for the former, the interference comes from > the outside of the affected process, for the latter, it doesn't. > > In other words, anyone may use smaps_rollup to probe the affected > process without the information about what step the affected one is > executing. Thanks, that is a good enough point for me :) -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4616C433DF for ; Fri, 14 Aug 2020 08:30:30 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B0A2220708 for ; Fri, 14 Aug 2020 08:30:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hUOZdnMN"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="a8EXI30E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0A2220708 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WaI/JZ+KFDjz6hdjQZJyQULSuI+AxVcTTMjRE8ALh6s=; b=hUOZdnMNmhtfj3pXXPpiU6R9V SlSLe7toRREhd7BdvI5SQhseNhWA1aMgBSklKmnbC2sKTxIzGQwzqlk4N9vqPBmCGHoJFY5mmnmnp 7kkulhBTT6Pv3PAtovpsuhtH9U5mhQVhAlwrDj/hmSXZhrWYaiSunEyBDRnO2Fvr0g6U9lIfWssKo 4NKJptl/Iet53yMGt3mjX/yqzES0aDMhQ1m1UPjPwm5z/c1/GeDvGxsT6dJ61N9PS7ufi5hbxaj5X MEKhI7Ezah3XG1VrMPjucdBmVd6tgH2ltI0rF+Rae7YzTCTNjKvHN5pd1OFPNNicw/mMiRY8IDue6 fD0ysN7+g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6V6S-0008M6-Ai; Fri, 14 Aug 2020 08:30:20 +0000 Received: from mail-yb1-xb42.google.com ([2607:f8b0:4864:20::b42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6V6P-0008Kl-8z for linux-mediatek@lists.infradead.org; Fri, 14 Aug 2020 08:30:18 +0000 Received: by mail-yb1-xb42.google.com with SMTP id m200so4781595ybf.10 for ; Fri, 14 Aug 2020 01:30:15 -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=3FTYvzqtwTFg32oQ2R1iT/fxQYwIO5aEnRMfUKVR7Oc=; b=a8EXI30EnDIPpIpx03Sd32eIfrso3BfcxnHyuAmDr5hmLTex8csYsnA9uZ316d8+bV sOEB/63/jWXUQXNPxzlvTziNsLhCzV+LYdqyR66PA/ZKL9aedLGB3m7E4J7PJ96iMNP1 HkdlGmEzCWqRKidgDrvMNP43EbLGV/cRtR73DUUrI0yxZ05fIi5y0fZQtvuqF76mORow zHCXH/esL0lg5ebyMvZHR4aV3OCvpJAPEMnkf656Epo4coILnvz6InECDbGlBQGQHcM0 YlurOpy3r0mZ0QR5hMkDdcvD/SLUmXa1Naesw9cyAoE6/0caKGpBdG4cUvKyjsTkjI+M J5lQ== 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=3FTYvzqtwTFg32oQ2R1iT/fxQYwIO5aEnRMfUKVR7Oc=; b=oasYuBE+dLTw7IlZGe02a6gk0cU0ctPO01hJYCHTb0CPnxO0NNDgPfEjmeYEYRJr4x DD1hNg1JVQ5FDp0yAWENrkYdACu8+60fSAmPydREX9fyzJcra+BfQKuGG5pCpf99lMXj 2HhTRXhiySW7QN9AP1egBwCvD8uwhCvGj5+5LiVVMI8l4H/UrGWvCH0o08k/1j64UAJg 1gV98qYFVp8kXacVGU7dcOlgH3F//chXuKC5oL6EQLEGLtYlYIwbnBwI46DFR/9U77m0 PoVBZx+6UwnodSxovQ7LR0YQNoSHh25FuMEs6Y75OSIaHM/HPEUnjjZqg8Dbv/6dKe8D ozsw== X-Gm-Message-State: AOAM5312cVq45WxaorBNQ0MsGcOfadc3amI6qZPz/B86bvtb0uvSDeCh cdpNMn7KXJNsGz6O80dsLkY32AnJgOrbiYRwwWzMrw== X-Google-Smtp-Source: ABdhPJw13pPX/3kPqJmeuWDN2VsAFdhKvqiSsbN8Cuj1qsFtz1LjVZiTxa/qFhrVFcgAEIezPtI+eYfXKR4LKmD5VnE= X-Received: by 2002:a25:e684:: with SMTP id d126mr2335998ybh.332.1597393813820; Fri, 14 Aug 2020 01:30:13 -0700 (PDT) MIME-Version: 1.0 References: <1597284810-17454-1-git-send-email-chinwen.chang@mediatek.com> <1597335088.32469.55.camel@mtkswgap22> In-Reply-To: <1597335088.32469.55.camel@mtkswgap22> From: Michel Lespinasse Date: Fri, 14 Aug 2020 01:29:59 -0700 Message-ID: Subject: Re: [PATCH v2 0/2] Try to release mmap_lock temporarily in smaps_rollup To: Chinwen Chang X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200814_043017_461740_91B2F21F X-CRM114-Status: GOOD ( 27.43 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Song Liu , wsd_upstream@mediatek.com, Davidlohr Bueso , LKML , "Matthew Wilcox \(Oracle\)" , Daniel Jordan , Jason Gunthorpe , linux-mediatek@lists.infradead.org, Jimmy Assarsson , Huang Ying , Matthias Brugger , linux-fsdevel@vger.kernel.org, Andrew Morton , Steven Price , Alexey Dobriyan , Vlastimil Babka Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On Thu, Aug 13, 2020 at 9:11 AM Chinwen Chang wrote: > On Thu, 2020-08-13 at 02:53 -0700, Michel Lespinasse wrote: > > 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. > > > Hi Michel, > > Thank you for your kind feedback. > > In my opinion, the difference between the case in smaps_rollup and the > one in your example is that, for the former, the interference comes from > the outside of the affected process, for the latter, it doesn't. > > In other words, anyone may use smaps_rollup to probe the affected > process without the information about what step the affected one is > executing. Thanks, that is a good enough point for me :) -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies. _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97661C433E1 for ; Fri, 14 Aug 2020 08:31:55 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 630DF2074D for ; Fri, 14 Aug 2020 08:31:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="iW4/jQUq"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="a8EXI30E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 630DF2074D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=irkrSZONIzUGprIvfM9k7izH0QeAeyvCxQAK64Lk9r0=; b=iW4/jQUqW6nXL7O7ujubVj4gz d0Wr0Z9QCqynkjsqz4c/o3i1fRXcTa8spiasbf8baQgz0jjogBPueMmDtf9qXP2YYVdi2pEzGyvDY gd3viURVRa54YdERMXqyrQfotp/Jnf8kIse2xjFe8SxjnS0c+3AMGmKYDOrgeyAMsQxSrw7iLe/AY aCWFJ53flodA7WUDQ8d9EKG+x0MRe81m3p3BwBFSlsJsRAcxNl3YqEtR1+zWLcoM0foJac6Tdgayr Xrrk8MRSXmVsEFaHjV5gXp1nsen2ZfqwptlaXKFLP7b6LRj/g5nyd4N5uoCfARMbvLNBEtxr6rnJf MPM/Im6GQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6V6T-0008ME-DU; Fri, 14 Aug 2020 08:30:21 +0000 Received: from mail-yb1-xb44.google.com ([2607:f8b0:4864:20::b44]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6V6P-0008Km-91 for linux-arm-kernel@lists.infradead.org; Fri, 14 Aug 2020 08:30:19 +0000 Received: by mail-yb1-xb44.google.com with SMTP id x10so4762286ybj.13 for ; Fri, 14 Aug 2020 01:30:15 -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=3FTYvzqtwTFg32oQ2R1iT/fxQYwIO5aEnRMfUKVR7Oc=; b=a8EXI30EnDIPpIpx03Sd32eIfrso3BfcxnHyuAmDr5hmLTex8csYsnA9uZ316d8+bV sOEB/63/jWXUQXNPxzlvTziNsLhCzV+LYdqyR66PA/ZKL9aedLGB3m7E4J7PJ96iMNP1 HkdlGmEzCWqRKidgDrvMNP43EbLGV/cRtR73DUUrI0yxZ05fIi5y0fZQtvuqF76mORow zHCXH/esL0lg5ebyMvZHR4aV3OCvpJAPEMnkf656Epo4coILnvz6InECDbGlBQGQHcM0 YlurOpy3r0mZ0QR5hMkDdcvD/SLUmXa1Naesw9cyAoE6/0caKGpBdG4cUvKyjsTkjI+M J5lQ== 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=3FTYvzqtwTFg32oQ2R1iT/fxQYwIO5aEnRMfUKVR7Oc=; b=Nt8Us+6ZVkqfbdWTc+dgINirsgPWRNqoz2L86vawvDstYX0oKnRNvf7wFcxn5L3qly iyaDlhD3joVn2xfpEwJiv76j3k5XrPGcoDjAMA26J3qZWB4jxbTBMQ7R3+1iLIDLGCMb xG4o7zllLP91o7n0kRFeCNcKO5SJZ/EHuAI031bDQdf0BqPYYXkVB9WcwtaI+Ys9UdtF T5kQ8QQp6uv2yCfnl0GG6UTcRMrWzRwW2OI+L0BUM/oEWXP55Bbpe8Pha7DL2QZYOyce yxFzXCgTMwrYfQwteobsMbpcmHyv6odmu4dkDEZjJunNvaJOWcE6rcKG1xlFVro0u/fG xfug== X-Gm-Message-State: AOAM5315zZjH3KD1kIiaATkS7xzC5tcL7wqYQfiGwz+uYldFBUsQ5+ys fCMMFIeemeDFbGM5f1R6k1SVkcfL3RTsE/83RGQySg== X-Google-Smtp-Source: ABdhPJw13pPX/3kPqJmeuWDN2VsAFdhKvqiSsbN8Cuj1qsFtz1LjVZiTxa/qFhrVFcgAEIezPtI+eYfXKR4LKmD5VnE= X-Received: by 2002:a25:e684:: with SMTP id d126mr2335998ybh.332.1597393813820; Fri, 14 Aug 2020 01:30:13 -0700 (PDT) MIME-Version: 1.0 References: <1597284810-17454-1-git-send-email-chinwen.chang@mediatek.com> <1597335088.32469.55.camel@mtkswgap22> In-Reply-To: <1597335088.32469.55.camel@mtkswgap22> From: Michel Lespinasse Date: Fri, 14 Aug 2020 01:29:59 -0700 Message-ID: Subject: Re: [PATCH v2 0/2] Try to release mmap_lock temporarily in smaps_rollup To: Chinwen Chang X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200814_043017_485225_BAFB4A79 X-CRM114-Status: GOOD ( 28.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Song Liu , wsd_upstream@mediatek.com, Davidlohr Bueso , LKML , "Matthew Wilcox \(Oracle\)" , Daniel Jordan , Jason Gunthorpe , linux-mediatek@lists.infradead.org, Jimmy Assarsson , Huang Ying , Matthias Brugger , linux-fsdevel@vger.kernel.org, Andrew Morton , Steven Price , Alexey Dobriyan , Vlastimil Babka Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Aug 13, 2020 at 9:11 AM Chinwen Chang wrote: > On Thu, 2020-08-13 at 02:53 -0700, Michel Lespinasse wrote: > > 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. > > > Hi Michel, > > Thank you for your kind feedback. > > In my opinion, the difference between the case in smaps_rollup and the > one in your example is that, for the former, the interference comes from > the outside of the affected process, for the latter, it doesn't. > > In other words, anyone may use smaps_rollup to probe the affected > process without the information about what step the affected one is > executing. Thanks, that is a good enough point for me :) -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel