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 9E1ADC02193 for ; Tue, 4 Feb 2025 19:53:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D10F6B0083; Tue, 4 Feb 2025 14:53:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 17FA56B0085; Tue, 4 Feb 2025 14:53:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06F0C6B0088; Tue, 4 Feb 2025 14:53:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D79566B0083 for ; Tue, 4 Feb 2025 14:53:50 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5E23B1C84B5 for ; Tue, 4 Feb 2025 19:53:50 +0000 (UTC) X-FDA: 83083312620.18.331BBEE Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf26.hostedemail.com (Postfix) with ESMTP id C48F0140002 for ; Tue, 4 Feb 2025 19:53:48 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HuIiVLu2; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1738698828; 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=UOSZO3JTqvmYXQ4P9RBhRBLYKXieTd8rpAZvKeb+8ew=; b=sBayEXLZTBv1/cRtn/tprvhL1Q4xA1sYUrTwp/QuYaBw9s6Bs1cIImWVwFxnt5xj3KwLmo Y6/0ep7vPJeO4u5g/QECqckLwxGa+KdQfP1VKFxFCFzbN3dt9IWTsuEUEYYFnv1tZpHwPh ftCvfJw2YPR14iqRGZAtsphjOE3/AuQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738698828; a=rsa-sha256; cv=none; b=fIbn+GNUSK2eWjvM35xMzw23LP5s5YxYBRGWJb5GlTE8QfggCdoB0tHcX2PnWMvASdELh3 HEX7sYqbX9hmhLbRmvrwEi3S9FyIyzlwARyPWrMDA6fSadA6jHx2ELpizQ6qTGY2QWwvkM mO2weamO328UFi7xJtGdaj5Vpk6wKuE= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HuIiVLu2; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id CB01AA42D6B; Tue, 4 Feb 2025 19:52:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78770C4CEDF; Tue, 4 Feb 2025 19:53:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738698827; bh=YE7iLCsVMIkRgrPseqapZzwyo9OsMGafX9hSn73e1LY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HuIiVLu2PXRDvemu9WId344WZtFX8wSPlWNOiXQy305xuk9fxJUcrmg7rdIWzHOA8 a5gtwgiQlAEUcSqzMk8jxdF2oBsGKjK4I47N8vpHL2hU74dKdrDCE5OlN5roQzhGx5 PauTbEezbxmGiXCkX8ojJV0Ril2jsDqINSWrt3VJCPDg+7zYLfej2fkOpXWmdiPZDY cseCFoFUE+oab6OGbbHYSDh38EuaXVBAIbsoLDZ1kdb4kGIrSI9FXDzRfe0GqpO7vf DxFmsrUuJxNpP198ZfoHmA8uBZcp57Kh5jY6BkzvXSf/p3MFy7u59zd2vUq/9fRC5L eBGmxUk0xXQNA== From: SeongJae Park To: Lorenzo Stoakes Cc: SeongJae Park , "Liam R. Howlett" , Davidlohr Bueso , Andrew Morton , David Hildenbrand , Shakeel Butt , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH v2 4/4] mm/madvise: remove redundant mmap_lock operations from process_madvise() Date: Tue, 4 Feb 2025 11:53:43 -0800 Message-Id: <20250204195343.16500-1-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <5fc4e100-70d3-44c1-99f7-f8a5a6a0ba65@lucifer.local> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: q8977dh4y17mfy6cm9n67a6mom3qzzzt X-Rspam-User: X-Rspamd-Queue-Id: C48F0140002 X-Rspamd-Server: rspam03 X-HE-Tag: 1738698828-864841 X-HE-Meta: U2FsdGVkX18Qf3thMS4WOlcQ8oNgSd3xuMxNmJg4xyerBx0RbfCZP/5ehDeRSPv5+7u35zpOp9GBZA2RnLcr80bM2FEVxGHTnAXQ9scZxYXKWcxFHAXB5hL632NFUblYd807Yj7BKrbP/ngs6XG8sjK5+cvsjQmIbknydlUsZk/tUStTxUKIq+m+9tsRoGHs3aUk7HsgC2msPOor7uFYJzLXTQA520BI56GKSa4X2dWelcasSIiZFKYQpmJarauJ/b4Ifph+gk1zTdEq/Uon4s1+92zXuSgk32z3u9l3zS0GfW3OQLuT8MGvka2TaxyLI75v22IGYaKm5rbsPLkhG3Z2qxEvI+Np86/3CyuqU/OjOZLN989729hn9W6td2uJkEulDV49znSqGTozcR7ifD0laZQpFXIqNzYC+8M0d6Mbxhz0JkP7AuSOV4oOW60u6bWY7H3UOgwfMKNnUmPIcwhli1b1RG2RewFVT4PoKFHr1KlpaM3fN0HOV0HWWSNWajzL4z62onhH0pqrm2jRi7VBEvrTTAJY0GsE2dY59L8z7sLLTuRTMQptUkVpDtUY+Zt3KemNCLM8P2lpfaJQDIHEbaOHEAAA7JKFwZCW8jLN1UFzZ03AWHJxZud4vdf/UpIyW4ONsuD30yLerDlRkFuJjkSDHsbn004PnfjTHofp0/fm7azGprmkTBxIevz9J/zVh+QGsw858vhNW1i0aG+1JAACda8uiLUseMGM8enfbvUaai5kJ+gN2vh8JYiRmoDu+im9AufuMvND1uqg+QiI+fFQMGfiVOxyxU8DnSM5Ze5oi0fT0LT0tBgeXZSFpbQDSI7b44siT6Zd+4TUsaIGzvP5FjJ/dU6e5Me+HhcRvJvanqO/5XlkUAPRZeCr6OIp93xWA8NotZwYlb/CamUnB1dEkrxiS3jKZZKYy+phfeARlrjgb7NqVahfgbzRskjKPRRPvUllzWDUC/r 8mZQflrz 17yiXBPYL8Dz4BA6c+QlAoAnB7UOyO3ZONrvJIW2oxE4wpxOmvPG/9uWFli9FF7WvIDqqhJngZ5z9Fhf2aIdkkk2xjq79w99txWBFzrjZk79edS9Cvh7rg4WRL/JfiVPR95polGuovERXlhF2G1DCqPYmgH2hYsWTnfynn6wP4XGaqwtLqNJFfI+IdvOxaCTfNomDJLAqn1javjY6jbS2EolUf6NuU6vc3/qTdwkdmn4tMQqDuDRnmAt40+mdHvedjL3zy2N7IsQz2UTUI3+IyBPklPRLz/G/mxn4scBP4NYsFSKCMJps3wVmQ7Hogah8p4hrVChhL+tjO64TucrZI355p+CX7+8vNKdAGR5nVEFkIkzH1iRjSwUlAB1Y5IsnTSe7 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 Fri, 31 Jan 2025 17:51:45 +0000 Lorenzo Stoakes wrote: > On Fri, Jan 31, 2025 at 12:47:24PM -0500, Liam R. Howlett wrote: > > * Davidlohr Bueso [250131 12:31]: > > > On Fri, 31 Jan 2025, Lorenzo Stoakes wrote: > > > > > > > On Thu, Jan 16, 2025 at 05:30:58PM -0800, SeongJae Park wrote: > > > > > Optimize redundant mmap lock operations from process_madvise() by > > > > > directly doing the mmap locking first, and then the remaining works for > > > > > all ranges in the loop. > > > > > > > > > > Signed-off-by: SeongJae Park > > > > > > > > I wonder if this might increase lock contention because now all of the > > > > vector operations will hold the relevant mm lock without releasing after > > > > each operation? > > > > > > That was exactly my concern. While afaict the numbers presented in v1 > > > are quite nice, this is ultimately a micro-benchmark, where no other > > > unrelated threads are impacted by these new hold times. > > > > Indeed, I was also concerned about this scenario. > > > > But this method does have the added advantage of keeping the vma space > > in the same state as it was expected during the initial call - although > > the race does still exist on looking vs acting on the data. This would > > just remove the intermediate changes. > > > > > > > > > Probably it's ok given limited size of iov, I think so. Also, users could adjust the batching size for their workloads. > > > > but maybe in future we'd want > > > > to set a limit on the ranges before we drop/reacquire lock? > > > > > > imo, this should best be done in the same patch/series. Maybe extend > > > the benchmark to use IOV_MAX and find a sweet spot? > > > > Are you worried this is over-engineering for a problem that may never be > > an issue, or is there a particular usecase you have in mind? > > > > It is probably worth investigating, and maybe a potential usecase would > > help with the targeted sweet spot? I think the sweet spot may depend on the workload and the advice type. So selection of the benchmark will be important. Do you have a benchmark in your mind? My humble microbenchmark[1] does only single-thread usage performance evaluation, so may not be appropriate to be used here. I actually do the evaluation with batching size up to the IOV_MAX (1024), but show no clear evidence of the sweet spot. > > > > Keep in mind process_madvise() is not limited by IOV_MAX, which can be rather > high, but rather UIO_FASTIOV, which is limited to 8 entries. process_madvise() indeed have iovec array of UIO_FASTIOV size, namely iovstack. But, if I understood the code correctly, iostack is used only for a fast path that the user requested advicing less than UIO_FASTIOV regions. I actually confirmed I can make the loop itrate 1024 times, using my microbenchmark[1]. My step for the check was running the program with 'eval_pmadv $((4*1024*1024)) $((4*1024)) $((4*1024*1024))' command, and counting the number of the itration of the vector_madvise() main loop using printk(). Please let me know if I'm missing something. > > (Some have been surprised by this limitation...!) > > So I think at this point scaling isn't a huge issue, I raise it because in > future we may want to increase this limit, at which point we should think about > it, which is why I sort of hand-waved it away a bit. I personally think this may still not be a huge issue, especially given the fact that users can test and tune the limit. But I'd like to hear more opinions if available. [1] https://github.com/sjp38/eval_proc_madvise/blob/master/eval_pmadv.c Thanks, SJ > > > Thanks, > > Liam > > >