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 1F81DC3DA7F for ; Thu, 15 Aug 2024 18:17:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 799736B0147; Thu, 15 Aug 2024 14:17:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74A516B0199; Thu, 15 Aug 2024 14:17:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 610B96B019E; Thu, 15 Aug 2024 14:17:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3B7AD6B0147 for ; Thu, 15 Aug 2024 14:17:08 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EA70B1A16D0 for ; Thu, 15 Aug 2024 18:17:07 +0000 (UTC) X-FDA: 82455286494.20.BA026D0 Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) by imf19.hostedemail.com (Postfix) with ESMTP id 145981A0004 for ; Thu, 15 Aug 2024 18:17:05 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=GKIw7gWn; spf=pass (imf19.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.160.52 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723745789; a=rsa-sha256; cv=none; b=qPmyUMHaB4ZN978wEOa3wRRW5wJuz3d3pVp1nEsUYwu4Fa8mqq2FnovmfrphQcQbo/Mjz/ YcDEkGLx4DI04W4MOHNgwaDES/575e5F8OfadYt3L0WNQXWiSsMHGAa6C2VipRDCE/6wkp 11d8e4Rys6pq1YB+FXqoDvSzJdawwZM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=GKIw7gWn; spf=pass (imf19.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.160.52 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723745789; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WulVhf/lbrXtVuEvrtHRPg80DRz2GQqwnIZEq09+IRc=; b=vcrRJc2gOhzPZihMDPmaZnD0QD7R033MDeJjnzjCUg3QsUoLBJRDHO8eilX5ZBPj8FVU+X CLll478vvJ+s43KbYIzjezdjkvncT97Vc8L56xCDKYA+lK4PH3l4rZoM9a9tkTn/Cpxgjw WQ5cDXoRJadsQZ5OaBGegeplaPsnHs0= Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-2700d796019so436918fac.2 for ; Thu, 15 Aug 2024 11:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723745825; x=1724350625; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WulVhf/lbrXtVuEvrtHRPg80DRz2GQqwnIZEq09+IRc=; b=GKIw7gWnFy7eyQd2gVtlmKKRuPvD6FlSO7tNwf+ZiiZwBfyKa5HXnkE3hAtCGu6kUb xPiCtmZkL0eWdzX4vOZNGmLTYGlYbb3MzXh3AyitjJo4bh6o5ILihhN6MEd3TNocJRzW Bf+Edm27U/8YnBovRrXt/Xcwbm5lEyLXh7owE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723745825; x=1724350625; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WulVhf/lbrXtVuEvrtHRPg80DRz2GQqwnIZEq09+IRc=; b=dryG7zBwjKZMOSZjtEN2LCmQS+Clt/TbE5g0SdKlhgFNkaRRcJDlLngVaG9AmMy3mg 1Js/pHOy1+xMAfCe45yg8tbhCLFZibrl9gdEhg+GVUcOfi6HkZ0f/htWzzP5x3iDmq17 e5SAmKYIkA+bN1oo1sdghxnGrcHpb1v6nCxI27W9yfrOsWm2T9tnlAT7Cm+1fHkP/5Cn LGNWN2XRzfSesBJQqxtl7Hu9YsLiQOxMnFBZAXIKbLGq5UylnkfkmKVmLCzGDNABsbfl fsIt8UOxchmZ3sdhqCAnBvtIA/IOmMcAVlG+fBS3JsoqQaFKqTR4HzpdaZcbTWn0XnRi zlJQ== X-Forwarded-Encrypted: i=1; AJvYcCV0prjITPvIXUbffwuWWJY8dPyyuxzb40CkKG5fOmsX2S3oOPs9SaqlSLQQYtSROVsiHB4vrsl1FAGEERSU7dMwTLc= X-Gm-Message-State: AOJu0YxI0YsCPoFZBJ/p4pWoTfLXb3AzTMffwJ91P69v/+oHP49ME5EE SMxHs3TkXvkPsFiiwNrxLTWpV0fPKOlwg3RHiKyfhYBrmrL2x4Avimh2ZTf2DqZkVz8K2GQI5Aw p4j4NsqAPiVo/HWvaPjEQU31WRylHeAJlDYZA X-Google-Smtp-Source: AGHT+IFBzd2labGfip0TWIus/Lddyszo/RVNbmgY3SlorSK9faJ6vZdtzGx4sbNKmzII4n+Xp0V1AtaK3L5PzzXifXs= X-Received: by 2002:a05:687c:2bea:b0:270:1cee:ab9 with SMTP id 586e51a60fabf-2701cee16d2mr297534fac.16.1723745824775; Thu, 15 Aug 2024 11:17:04 -0700 (PDT) MIME-Version: 1.0 References: <20240814071424.2655666-1-jeffxu@chromium.org> In-Reply-To: <20240814071424.2655666-1-jeffxu@chromium.org> From: Jeff Xu Date: Thu, 15 Aug 2024 11:16:52 -0700 Message-ID: Subject: Re: [PATCH v1 0/2] mremap refactor: check src address for vma boundaries first. To: akpm@linux-foundation.org, willy@infradead.org, torvalds@linux-foundation.org, Liam.Howlett@oracle.com, pedro.falcato@gmail.com Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org, jeffxu@google.com, lorenzo.stoakes@oracle.com, mpe@ellerman.id.au, oliver.sang@intel.com, vbabka@suse.cz, keescook@chromium.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: 5ig3ojw5a98w7scmazt5gaze3z41hoc1 X-Rspamd-Queue-Id: 145981A0004 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1723745825-421063 X-HE-Meta: U2FsdGVkX1+Gn7dEHAmRFsleNHoUUq+C9FKw/c/gePly0UmxQehHeEgobKF3ySLOjziHsp46o2JgkY0pp1QTcaPRt1lA0jjqjS7MXxfJbz3k4gVMRis2BSNNvCSL6XTMbcR93lN8zp2HCgiMn07eIRPX8Nnp2uaEwRMZxzzLh1SAbupPoakpx/nVBBjTAQGvy3S19dcCb9bbN4itKRUJO7IlZVyKO5VW1vQFQIrRJLvcUxbNsBzI2eChYF2xveCqEupPieRbeOnOTy5nb096SqUPkB2zqL48TbF0kwjbfPAFFfEAcs1AKFDSJT6CuGAEvnF4YeAdyTiMe4qLuTDPpV66LSmqMjfbf41RMVs+ev9uzzKqhkDqR+ApHSVsAdXsR7SDAEbzicYSMSengPj+3IeqBKrLlmSfTLIKYRkLknUC1q3HuuVMA400J1N4UTurKYytZw5l5voI2DadruyolLUcBNQbNGphNgPd7F1vocE5rxD5sxSSQvaMaTmfFjnI8Yqe1CcXoAOw1Uyga20aRvepP63bmFrdGI+izn+rxZg+nFXjSz6Ew3U9GHGIaGufsXD7wUb5GAYJoa4iAVPR0ERFAs1RFvMNmDz9kJR8F5Q2LiYdhH7Y0kNIHv0u1QeJP5ZpjV6zzt+2jIU5aGeBYm1GWwiuXvJIHAjS/iBL1iBCGQrgIViyphsmz78ZWkzPRCbTge2CsfWO+02FGHCbLUSEMXSumhj0kTSj78fEmSg1w9A9odwmdP4uoK9t/iAKsURfjJIenvzmCYTTSAn4pZm2rxyIueAVKYV5S9gQjBXI00ucHyRindn4vAKJUrKZQJRQAZdGjibl/YfvIcF2/QLU6o1LU0sVD6V1vSEJBu98dvgxxeaQ1VhEPJ8V9IbCHSWcqR8IdH0NPk5Iwyc2OmIm8OAgbyoB+ERtnE56Qh19S2efpy35+X/8khGEebsFlB+V4zR+3nHcoXTnuFp PR3SY7Vx tt270Qn9AdNCL8utR01kO/DASVKwqnqtClRQ3I/2HpvlUn8pZhw3ZVLgcWBwpFU3i2T2rW1iVndqm2SWY6oaSuSNfEQm6hpCxOqdJiU3azUkman9W9A6Cl02OoLso/BqDEK53xf67wCanXwa/hWS+I3nydc/XbDq8fTsT7U/V539xNLLaln8Zu2Kqg/VCXIOnYwZCpBpQdksEv7eXPsRVG2WyAzGaunQPCR5+EQf6QlMaT7JZrIlhTTV9JVBo3YrO9dkA8SAwMfR7AavAp8wIfziuAen+1rkkJ5Li4owoLHIbqmg1gB1AdORs+6ujhgmOidz1VgC4JvdHMAXBmumuIvkjdJs2rgu6TBqfmlXNXrcZXs7nTdjM4dKZZjL1+Sm5VSwRzWQQjo6BOIKdzkh1GvQ/m4Bel6XAXcFh 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, Aug 14, 2024 at 12:14=E2=80=AFAM wrote: > > From: Jeff Xu > > mremap doesn't allow relocate, expand, shrink across VMA boundaries, > refactor the code to check src address range before doing anything on > the destination, i.e. destination won't be unmapped, if src address > failed the boundaries check. > > This also allows us to remove can_modify_mm from mremap.c, since > the src address must be single VMA, can_modify_vma is used. > > It is likely this will improve the performance on mremap, previously > the code does sealing check using can_modify_mm for the src address range= , > and the new code removed the loop (used by can_modify_mm). > > In order to verify this patch doesn't regress on mremap, I added tests in > mseal_test, the test patch can be applied before mremap refactor patch or > checkin independently. > > Also this patch doesn't change mseal's existing schematic: if sealing fai= l, > user can expect the src/dst address isn't updated. So this patch can be > applied regardless if we decided to go with current out-of-loop approach > or in-loop approach currently in discussion. > > Regarding the perf test report by stress-ng [1] title: > 8be7258aad: stress-ng.pagemove.page_remaps_per_sec -4.4% regression > > The test is using below for testing: > stress-ng --timeout 60 --times --verify --metrics --no-rand-seed --pagemo= ve 64 > > I can't repro this using ChromeOS, the pagemove test shows large value > of stddev and stderr, and can't reasonably refect the performance impact. > > For example: I write a c program [2] to run the above pagemove test 10 ti= mes > and calculate the stddev, stderr, for 3 commits: > > 1> before mseal feature is added: > Ops/sec: > Mean : 3564.40 > Std Dev : 2737.35 (76.80% of Mean) > Std Err : 865.63 (24.29% of Mean) > > 2> after mseal feature is added: > Ops/sec: > Mean : 2703.84 > Std Dev : 2085.13 (77.12% of Mean) > Std Err : 659.38 (24.39% of Mean) > > 3> after current patch (mremap refactor) > Ops/sec: > Mean : 3603.67 > Std Dev : 2422.22 (67.22% of Mean) > Std Err : 765.97 (21.26% of Mean) > > The result shows 21%-24% stderr, this means whatever perf improvment/impa= ct > there might be won't be measured correctly by this test. > > This test machine has 32G memory, Intel(R) Celeron(R) 7305, 5 CPU. > And I reboot the machine before each test, and take the first 10 runs wit= h > run_stress_ng 10 > > (I will run longer duration to see if test still shows large stdDev,StdEr= r) > I took more samples (100 run ), the stddev/stderr is smaller, however still not at a range that can reasonably measure the perf improvement here. The tests were taken using the same machine as (10 times run above) and exact the same steps: i.e. change to certain kernel commit, reboot test device, take the first test result. 1> Before mseal feature is added: Statistics: Ops/sec: Mean : 1733.26 Std Dev : 842.13 (48.59% of Mean) Std Err : 84.21 (4.86% of Mean) 2> After mseal feature is added Statistics: Ops/sec: Mean : 1701.53 Std Dev : 1017.29 (59.79% of Mean) Std Err : 101.73 (5.98% of Mean) 3> After mremap refactor (this patch) Statistics: Ops/sec: Mean : 1097.04 Std Dev : 860.67 (78.45% of Mean) Std Err : 86.07 (7.85% of Mean) Summary: even when the stderr is down to 4%-%8 percentage range, the stddev is still too big. Hence, there are other unknown, random variables that impact this test. -Jeff > [1] https://lore.kernel.org/lkml/202408041602.caa0372-oliver.sang@intel.c= om/ > [2] https://github.com/peaktocreek/mmperf/blob/main/run_stress_ng.c > > > Jeff Xu (2): > mseal:selftest mremap across VMA boundaries. > mseal: refactor mremap to remove can_modify_mm > > mm/internal.h | 24 ++ > mm/mremap.c | 77 +++---- > mm/mseal.c | 17 -- > tools/testing/selftests/mm/mseal_test.c | 293 +++++++++++++++++++++++- > 4 files changed, 353 insertions(+), 58 deletions(-) > > -- > 2.46.0.76.ge559c4bf1a-goog >