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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83BCDC19F32 for ; Wed, 5 Mar 2025 19:57:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5385328000B; Wed, 5 Mar 2025 14:57:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C286280007; Wed, 5 Mar 2025 14:57:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3637B28000B; Wed, 5 Mar 2025 14:57:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 143A9280007 for ; Wed, 5 Mar 2025 14:57:46 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 867A5B7293 for ; Wed, 5 Mar 2025 19:57:47 +0000 (UTC) X-FDA: 83188557774.22.59C85FF Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) by imf24.hostedemail.com (Postfix) with ESMTP id 9B77C18000E for ; Wed, 5 Mar 2025 19:57:45 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Q1y+8z1x; spf=pass (imf24.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.173 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741204665; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0BZ45IvxuT1CTbxL4RXBvU3iDHOginUNtnpFE38cxuc=; b=T1IJSMl9c70uN9nukAL9oHTZCVjqckl/3IyB+VXhFFbt20jDydOY6IBCkjPqbXdxyX/sCJ HplZoBj9pp3brq/Pv4MfxQZlWtHVkXf1Jr+8fcGEzBPCIGBKInGmdBF7mxoJZ5DweIAO10 il9tUzTbRsWps400pD2BB0H87j7Wgmk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Q1y+8z1x; spf=pass (imf24.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.173 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741204665; a=rsa-sha256; cv=none; b=JuZ0axYxnauGmWYkxvXvNOmqdwXlt83v2+8fTH1FEnPDbz0sf6jUSTmRGcSi0uItDsEwWP ToXzEBFh0s1KZTDS85KXHjMcQ4PJgdIODHLwYNc4rdiNQ+ijoufv244lj5rcjImsMgTp8w r5jg/OudDbWApuzBZBl5h4dq1gtDays= Date: Wed, 5 Mar 2025 11:57:34 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1741204663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0BZ45IvxuT1CTbxL4RXBvU3iDHOginUNtnpFE38cxuc=; b=Q1y+8z1x5VgG/XpjBvKhsf+yFp15h+btREigmGTxucfx2h3D93SXm/7sToNWv3N60AK3e4 lq2Ft8dgc4UKKOiZ5Z+cvG7Kzkg18IWSOW9aI2u48P24dOumyVkFtY54ZNeibr/rUe4io5 C/Kz3QJnDDxILmjNuNnyIdIIOTi7blk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Lorenzo Stoakes Cc: David Hildenbrand , Matthew Wilcox , SeongJae Park , "Liam R. Howlett" , Andrew Morton , Vlastimil Babka , kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH 00/16] mm/madvise: batch tlb flushes for MADV_DONTNEED and MADV_FREE Message-ID: References: <20250305181611.54484-1-sj@kernel.org> <46960f37-0d12-4cfd-a214-1ddae2495665@redhat.com> <815d1f2d-4bc0-40da-ba07-42593ae7ee45@lucifer.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <815d1f2d-4bc0-40da-ba07-42593ae7ee45@lucifer.local> X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Stat-Signature: c5be3wtiscexr7mn8xp3t1h6xrou4c7c X-Rspamd-Queue-Id: 9B77C18000E X-Rspamd-Server: rspam07 X-HE-Tag: 1741204665-520026 X-HE-Meta: U2FsdGVkX193T2sLY3st80sb8Ow3Ec9qezJ1u8x9Z26cO9UwoetxGm57Q0nf0l9rMq+gQAAe3hwyiiT9tDqRr0ocrAzQiwLNNXxTCKs78Py/hbofdQNLArmG6Wquh1/zsNIbwXjsWlZ5EBNsIfCZAQMO3zRMlYDnBvwUZPSY0FhZ5XiksRwTXExttihs9yEm9huKdQeqdyopW5qcVOK/mA0nESlwKVeVtF5wFkTvkYe74b68dd8AohoFWDWiHnnc+yUZs4sxxB0sIHYDNzq2Q7GQApz5uVMYNJ/KQK8FeEqsFGE0gwfNwH5IbZdHBnvXEWZi1f3BmuuiJXIK7RN5sNJcyHz//LsdYA3YKYEyBhxyohCJE2SqI+eKjNkJ9EnsTJAF5q70svq8IYXdkT2P4Fmkv3HIROPYTbqHOmFwYfJz24p/NXyrq/32D3FTbHtPB5zjMkgZ1CRjtdeeoe6VdrWRUiUEQxopo1e2zvQr45aase08uI8Wg69rr8zcDan3L9fRLnwUEbg0qs/hsEDv4sFziD7qw8hDrPBDPHqpa5HdePb6+mkJjGGMWmFTQLif1/lhQjfyQfqPlJPy0ln/+6/Iiew8l0qBy7MyzaMnOMgAkjFt/uHjiCwdn0AVBbS5qW2SDJZiStGrQEFzCogY1N+JVa5aOzVHUGakNXVFx6PkPBR3fNaHEqqSWqPs7mOxOn8FHA44fBqishd90gM6sXx2pHZno9EtqWReQ8qi0EGREl21r7zZE9CTP89ahnV0GCdHryF/X0E2vCf+4V+0MY2DXZFumY9IKQeVcX2O/hPwrD1AucSgx8u+OfRzcLh+YBrLHC0hl3x0gerzeeerkCbsnBF+T6qzF5p/SgLPgy3EkG2OAOeETIof1NrJKtvUmxd2GamriXEf7hZpoN0b7/gctZ8aCKv7Xg49EfGtYY2w/ZcV6CyzGeJC0IJv3yOA9X0vGATvWLoNc5RMXZk C8d5bMVB BbYJ0XLUIolP+IOrXUCHImbb7wYHotZmXlu1Y+ifDOMqc47rPuqaL22cdjY5fmANg/i6lL47Xuzmaft1Sd1jvnwiDpJtNO5RuD9tMSE0ttfTx6p7hr1eIPRLSi37SOkQYGFY6F8r61jJPRLNgqxVXmRbKd3/XKbNJbUnrWVoMtbQXF8Jz9qlqHyK5AKIjnXz3oFC8BaVN6LBDRcJC00vEtZFffUjxbf4UTUabdUYoILWz8pY8kLkuie+9FAUFs4DslY2S X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Mar 05, 2025 at 07:49:50PM +0000, Lorenzo Stoakes wrote: > On Wed, Mar 05, 2025 at 11:46:31AM -0800, Shakeel Butt wrote: > > On Wed, Mar 05, 2025 at 08:19:41PM +0100, David Hildenbrand wrote: > > > On 05.03.25 19:56, Matthew Wilcox wrote: > > > > On Wed, Mar 05, 2025 at 10:15:55AM -0800, SeongJae Park wrote: > > > > > For MADV_DONTNEED[_LOCKED] or MADV_FREE madvise requests, tlb flushes > > > > > can happen for each vma of the given address ranges. Because such tlb > > > > > flushes are for address ranges of same process, doing those in a batch > > > > > is more efficient while still being safe. Modify madvise() and > > > > > process_madvise() entry level code path to do such batched tlb flushes, > > > > > while the internal unmap logics do only gathering of the tlb entries to > > > > > flush. > > > > > > > > Do real applications actually do madvise requests that span multiple > > > > VMAs? It just seems weird to me. Like, each vma comes from a separate > > > > call to mmap [1], so why would it make sense for an application to > > > > call madvise() across a VMA boundary? > > > > > > I had the same question. If this happens in an app, I would assume that a > > > single MADV_DONTNEED call would usually not span multiples VMAs, and if it > > > does, not that many (and that often) that we would really care about it. > > > > IMHO madvise() is just an add-on and the real motivation behind this > > series is your next point. > > > > > > > > OTOH, optimizing tlb flushing when using a vectored MADV_DONTNEED version > > > would make more sense to me. I don't recall if process_madvise() allows for > > > that already, and if it does, is this series primarily tackling optimizing > > > that? > > > > Yes process_madvise() allows that and that is what SJ has benchmarked > > and reported in the cover letter. In addition, we are adding > > process_madvise() support in jemalloc which will land soon. > > > > Feels like me adjusting that to allow for batched usage for guard regions > has opened up unexpected avenues, which is really cool to see :) > > I presume the usage is intended for PIDFD_SELF usage right? Yes. > > At some point we need to look at allowing larger iovec size. This was > something I was planning to look at at some point, but my workload is > really overwhelming + that's low priority for me so happy for you guys to > handle that if you want. > > Can discuss at lsf if you guys will be there also :) Yup, we will be there and will be happy to discuss. Also the draft of jemalloc using process_madvise() is at [1]. [1] https://github.com/jemalloc/jemalloc/pull/2794