Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp367636pxv; Thu, 24 Jun 2021 09:35:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwN42o/4C/TlCvayyM1HE2hlVFxSfQTRDuzYhuuF/xISbtxIsVa+50cwkmNOwWtH75FA7An X-Received: by 2002:a02:3781:: with SMTP id r123mr2358513jar.26.1624552523995; Thu, 24 Jun 2021 09:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624552523; cv=none; d=google.com; s=arc-20160816; b=IKpfY3QHYVaq078w3doexctPLFJy2v+RgZk4Rh1PlJPus8ziWEgQdxOBrqWotdZzGP U2EnB2YAngXTOgAo88gwkqwO29NThKFPHFxT6yHenjqgf+7t2vViLevpvZpEE3V0Xzjc Os4sArN7N/u9yoJo1I29btzav+nZmAuYaYTB6Z+fMrHSJyxp0PW4+USwek1jBwsJlegb fp2yvTRUr0t3CYXKbrnw/6P5HMrPPV/EMPsLZuotK+d4m6dYV+15u+k9wSBxceOJnANH D5vlxsN/b+m7xyoF8E6wqRg8EAt2kLihrFLwoujEcdeHzhpo5oR0XwhFKc+zLIvoyhMd 92ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6+6AW48CYbAMx4zT8RExeRCMx/Kaeq/I74QmDikRucc=; b=Gdis8FzTK5j15eBD5E7EPtJcKGsd0JIK72xyxi3+/TT2/KZLsGGYSqVETNu+DuWXx+ /LqF9XFF60beTQWZEHLtOR3egAZ2b6BqSx1kI0gN42n8oYLQrLxK0uttjlUlU2YHvDZu hJPEfi3ucgsHID5V82+7MN2VLuKZXqdCcjJVYbPM2Jc3xIQymvWnISCe/Y5p178l1nl7 AeOzoknVGc9p5Pb1dRXDjv7aDmEkxTPETNVJDjViWlI0P0THx1MiiTm5RwPrN17qQTXv l/1WVDm741fw+kPaDFNTe/hDf4dhbUAhMmfNCWzlCl/UfOAiiZorVlWhQkKb/Vgdp9B4 m3qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=im0cOOnq; 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 o4si3640921ilf.96.2021.06.24.09.35.12; Thu, 24 Jun 2021 09:35:23 -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=im0cOOnq; 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 S230450AbhFXQfk (ORCPT + 99 others); Thu, 24 Jun 2021 12:35:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229995AbhFXQfk (ORCPT ); Thu, 24 Jun 2021 12:35:40 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D7BFC061756 for ; Thu, 24 Jun 2021 09:33:20 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id h15so11245102lfv.12 for ; Thu, 24 Jun 2021 09:33:20 -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=6+6AW48CYbAMx4zT8RExeRCMx/Kaeq/I74QmDikRucc=; b=im0cOOnq6LVaPRTNRxRDOz1ygnhIbbUlF9c6CS20ddaGvqg9ISHVWTIxkTD8uFm1Tv u3ZGXCe4umDiHot1yi+v8XBgPbyMjDEB3nlFhdzW8hV9C6xuX5aTEia4k9QR9Ntfkq23 Cey67c4Ud3K0ry/gMPGLqUz6Dpa1Y5UevnKBtNNp4cprAeEALRGtI9v6CdDjBX12uvoF ukJeU+Ve594cwv6THXfMcCwGT6f4MgBD8zTM9iF6RZS3Yle9z6aiJtEfJ1qzXOipYmve Q+3f1F8HrcIzc4ZDU7rdAJVeH9eW0QJ8ZJGhB9xCjdGFTwNMQUFDfzfg5KbDooMbpxkY moQA== 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=6+6AW48CYbAMx4zT8RExeRCMx/Kaeq/I74QmDikRucc=; b=tMX7e8G+fofH9HKDl+cOJIFZGWw8tyBOZjsPNvJGftaNMmM7dSaWcuPf4DnM0xNAP9 ryAURGdHe5FmwnG2NaBI2tHJzgbdqJwv3t7+zm9/KSPfnDkpYSlbVves7PatBdQ/y/Lw ZzR+68efzOnpEsyAHUZZvvvVI+cN5ZOqBDEJaDN57QPWUjEF79ked4Dzw+BlXNfGTTgL YVb+dc4zpZ/GlTRG/ALIKOVzeSKJ1V+jbaTwdVWKqVv48B5OWbp3EBJIOlHYCbTLwE0m DIe+HX5LOSAGeST0wKPSsZDZ7GvsT89acKgax2UwtGsekEmYOFIU0PwL9a94n+MxMSbn eEMA== X-Gm-Message-State: AOAM530Achj41Xb6qdk7M9OjEirHFRAZhKoR0p0E0Ms/J6hMpZodHrGc 8DbpF63AakAXpyMnAnK1O6T79H047ALRxZVIrMboLw== X-Received: by 2002:a05:6512:1191:: with SMTP id g17mr4488372lfr.347.1624552398592; Thu, 24 Jun 2021 09:33:18 -0700 (PDT) MIME-Version: 1.0 References: <20210624152130.877-1-sjpark@amazon.de> In-Reply-To: <20210624152130.877-1-sjpark@amazon.de> From: Shakeel Butt Date: Thu, 24 Jun 2021 09:33:07 -0700 Message-ID: Subject: Re: [PATCH v31 05/13] mm/damon: Implement primitives for the virtual memory address spaces To: SeongJae Park Cc: Jonathan.Cameron@huawei.com, acme@kernel.org, alexander.shishkin@linux.intel.com, amit@kernel.org, benh@kernel.crashing.org, Brendan Higgins , Jonathan Corbet , David Hildenbrand , dwmw@amazon.com, Marco Elver , "Du, Fan" , foersleo@amazon.de, greg@kroah.com, Greg Thelen , guoju.fgj@alibaba-inc.com, jgowans@amazon.com, Mel Gorman , mheyne@amazon.de, Minchan Kim , Ingo Molnar , namhyung@kernel.org, "Peter Zijlstra (Intel)" , Rik van Riel , David Rientjes , Steven Rostedt , Mike Rapoport , Shuah Khan , sieberf@amazon.com, snu@zelle79.org, Vlastimil Babka , Vladimir Davydov , zgf574564920@gmail.com, linux-damon@amazon.com, Linux MM , linux-doc@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 24, 2021 at 8:21 AM SeongJae Park wrote: > > From: SeongJae Park > > On Thu, 24 Jun 2021 07:42:44 -0700 Shakeel Butt wrote: > > > On Thu, Jun 24, 2021 at 3:26 AM SeongJae Park wrote: > > > > > [...] > > > > > +/* > > > > > + * Get the three regions in the given target (task) > > > > > + * > > > > > + * Returns 0 on success, negative error code otherwise. > > > > > + */ > > > > > +static int damon_va_three_regions(struct damon_target *t, > > > > > + struct damon_addr_range regions[3]) > > > > > +{ > > > > > + struct mm_struct *mm; > > > > > + int rc; > > > > > + > > > > > + mm = damon_get_mm(t); > > > > > + if (!mm) > > > > > + return -EINVAL; > > > > > + > > > > > + mmap_read_lock(mm); > > > > > + rc = __damon_va_three_regions(mm->mmap, regions); > > > > > + mmap_read_unlock(mm); > > > > > > > > This is being called for each target every second by default. Seems > > > > too aggressive. Applications don't change their address space every > > > > second. I would recommend to default ctx->primitive_update_interval to > > > > a higher default value. > > > > > > Good point. If there are many targets and each target has a huge number of > > > VMAs, the overhead could be high. Nevertheless, I couldn't find the overhead > > > in my test setup. Also, it seems someone are already started exploring DAMON > > > patchset with the default value. and usages from others. Silently changing the > > > default value could distract such people. So, if you think it's ok, I'd like > > > to change the default value only after someone finds the overhead from their > > > usages and asks a change. > > > > > > If you disagree or you found the overhead from your usage, please feel free to > > > let me know. > > > > > > > mmap lock is a source contention in the real world workloads. We do > > observe in our fleet and many others (like Facebook) do complain on > > this issue. This is the whole motivation behind SFP, maple tree and > > many other mmap lock scalability work. I would be really careful to > > add another source of contention on mmap lock. Yes, the user can > > change this interval themselves but we should not burden them with > > this internal knowledge like "oh if you observe high mmap contention > > you may want to increase this specific interval". We should set a good > > default value to avoid such situations (most of the time). > > Thank you for this nice clarification. I can understand your concern because I > also worked for an HTM-based solution of the scalability issue before. > > However, I have neither strong preference nor confidence for the new default > value at the moment. Could you please recommend one if you have? > I would say go with a conservative value like 60 seconds. Though there is no scientific reason behind this specific number, I think it would be a good compromise. Applications usually don't change their address space layout that often.