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 96B59C19F32 for ; Wed, 5 Mar 2025 22:46:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62533280003; Wed, 5 Mar 2025 17:46:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D5F5280002; Wed, 5 Mar 2025 17:46:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C4FF280003; Wed, 5 Mar 2025 17:46:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2C2AA280002 for ; Wed, 5 Mar 2025 17:46:33 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 48EE8C071E for ; Wed, 5 Mar 2025 22:46:33 +0000 (UTC) X-FDA: 83188983066.29.281C461 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id 8AD3F100006 for ; Wed, 5 Mar 2025 22:46:31 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=l7Vyqi2+; spf=pass (imf14.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741214791; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zObuvGzFByos7TvXATsYpMsVuyrUVLEyES3Xiy3N7NE=; b=C2m9KQTQLi+cDMRqsL8a6aduAqbmaju7YZQZiY3gryv4mdMYl6LeLma0y85R6uqWKy0beW gMfVwTHMx8okZLGvukbmN/g90VOQRRkA/cZLfKpapsXDXtMV/iI/DbBFj/mbokFmALCOGh ImdOTjRLMf7SQKcLJrBQhw5wgN8BlKQ= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=l7Vyqi2+; spf=pass (imf14.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741214791; a=rsa-sha256; cv=none; b=HjldKR1gg7sGbpWQjKvT2MmDAal4RZW18CPtzBGFgnGUxcXR5PTdEKV7Lee8S/sGWyRzst 2JZeVKpuV2JtT9+tw6O5fIQCNa6oebqoORnoyvfaW7fMmayxiuV1YYalmHDI2EW2iaUSc9 qkMJtVcsmmHTfMAcQag5aGc8W1ZLPp4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D53BD5C4B12; Wed, 5 Mar 2025 22:44:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33409C4CED1; Wed, 5 Mar 2025 22:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741214790; bh=3Tg2RBK2X/sKpN0IUIrDSPGWkJ7RP0iQK0OMYcbbzUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l7Vyqi2+sWOFn/mQ+3Z6oWceG1MLz4QQAB+wS2Rys3hiHQd6GUqH7+kK18077Uh/q 4qWbYq1pymPuv5tzt0yqsDQibPMocIc85wIbYd3Z/AQvCGOqh6wxyL52OID2hhi+ZD WBrQy0yFyVuJtstZNMlR/pYr7ci2gkD/jWgPDWNHMpNJtj3Vt4cilslsYaxwXNKG5q CPdB4mHlW7j2tHPWba9/qKZg5fEIqOT+ewSNpinX8gGLpmyvN7IZvqrguEGngsMwpp 0NxaWHk2KwXO8EMWIdKFcNofvJdMw/8UMyrB+CI9sbY/El94YbJuoXnYUrQR/mWfDq 05oapb7VpEoEQ== From: SeongJae Park To: Shakeel Butt Cc: SeongJae Park , Lorenzo Stoakes , David Hildenbrand , Matthew Wilcox , "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 Date: Wed, 5 Mar 2025 14:46:28 -0800 Message-Id: <20250305224628.60041-1-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Stat-Signature: 8z8ubh8fkgs3u7ao4qfxn5d4ebww39u8 X-Rspamd-Queue-Id: 8AD3F100006 X-Rspamd-Server: rspam07 X-HE-Tag: 1741214791-459930 X-HE-Meta: U2FsdGVkX1/sHHAALHLmqMSvPiq4foYC7pf+/RfrBOmZrcVIq02dPjNIY5fRS2IIMJdC9QQ/EkAMmXi9TGBu9eRs7EgFaFqLoRO2mNjg86h0GaoTVFA4xHFnXPOT6AiUc3GxZphTSdPczXEyyRGgnRJM4FdI9f/WfQ6ILSPlqLnUDJMb8Y0+hInYWfY3DfU+YfsELzZygsgfzor4MzgY51ocK1RpiWCFtgEK1Sc7lGeorSoN0fhSKv3uF0eSueZjFYSMIGuarBKfrYd6V9sxaLUJKEdyWgHxeIMyBHHhvt8MP72VhP6nnJ/sHPHykC2YcoP2i0LyTCaKGc8tMR1mDT9tAO5QaE5+a5pqB3WSby0tJcvnYH9p+Q9ws1RcP4rkFJwRQGKOzrK6XtSqhsuaUzogm2GnBdNbWPhrbnsb426Aii51kQprOs3gNLDOpurYG0JVX7Of0SYfxiLvDbr7Cs3pkIURbEJTbSU+s2vL/ZUkKAbboXFhU3QkD0wF7211zEVOsIyaz+QfDQNcX6v3jWHrj/Nw+Bxo/bSOl5TUTKjT2YWdHfr+PIw7+MB4pqJm5oSCE8sVDCHge/4VRTSw2UY+00DnXRlYjvDXtZQsqR0ujSwPVHtOC4+Ot2sahyfJmJcrd/qAPx/o8noLOscipsXwUZ+ld+N/oBNYZ0XqaJlk9NwddLBQbPEKoqtL5m2g5Rx2Qjcp2lQFmFxvuf1NDQBvArN1qzTlX6h2Hb/PoIgQ/vRmkvNOQj+Vbo2ZLBB+u4gZ4yn7szFBiXjV/agSo/pCvZDQIyaJc8xwZpQXwDYAMh2pnGlk66u+ASi4yHZEZL5tQFMLi3W0XC0IUDwfCy5gsgwRV/kdrWyo9Nf0uVMdr4CcWudUBWDC5nc7BOqxbHxkv4wTpgVXGXfpaOP9vmdHwwQ23H6Eecpam4WKZP2K/pNxzrr5K7u3xOdkAUwrPh2iKZ5NBDAHfligBcl c5Ob/XOU +2hSHuI+bF2DsJCBItsFDQmfl1IbAsq6yr/Q3qjUL+VdafPm6Ffijyntqc8ZAD9IScBPpjMaHsJYyo1K84MMDwUmflC7MQqWee/JSeFyyURuL+CxXCDwpdy28UtolSQwn8Tjt7OtDtT3HOEkN7HGTNm/HDBtY2wENzOTXyFWX48Mu8G1RmpV9xIcpRyTWl0fgvp0Nd+WSK0Vxxc6nBW4KAYUkaFCcN9RaXOD6ANA1eFwKVg8lnacTBUnn1y1xZwAPo/QF 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, 5 Mar 2025 11:57:34 -0800 Shakeel Butt wrote: > 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. Indeed. Thank you for opening up the door, Lorenzo :) > > > > > 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. Me, too. Looking forward to the day! Thanks, SJ [...]