Message ID | 20240817-mseal-depessimize-v3-0-d8d2e037df30@gmail.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 D880AC3DA4A for <linux-mm@archiver.kernel.org>; Sat, 17 Aug 2024 00:18:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5199D6B00DE; Fri, 16 Aug 2024 20:18:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A1E26B014B; Fri, 16 Aug 2024 20:18:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 369DA6B014C; Fri, 16 Aug 2024 20:18:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 168296B00DE for <linux-mm@kvack.org>; Fri, 16 Aug 2024 20:18:41 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C53DD12039A for <linux-mm@kvack.org>; Sat, 17 Aug 2024 00:18:40 +0000 (UTC) X-FDA: 82459826400.27.3328D52 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by imf15.hostedemail.com (Postfix) with ESMTP id 020EEA0006 for <linux-mm@kvack.org>; Sat, 17 Aug 2024 00:18:38 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="BttZK01/"; spf=pass (imf15.hostedemail.com: domain of pedro.falcato@gmail.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=pedro.falcato@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723853860; 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: references:dkim-signature; bh=FURCjfhnzhcGGezKZU8awwiF5O22NwDdSRjockESBWM=; b=nFfpldxDXvy07NToDDYb4XlCJLwhbJ85v1x2rLJYNSEWeUN/C24UPccFQbQ29mE2o1c680 wBS507mqP33tp/TB8YmO1+gUSgOs+RlMGmgEhyz5r4BGgAsaQD31+Kla4x8bRGm5xUKMJB 2cKCBW4pqno94SNF8eu+QoWa7TZf35g= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="BttZK01/"; spf=pass (imf15.hostedemail.com: domain of pedro.falcato@gmail.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=pedro.falcato@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723853860; a=rsa-sha256; cv=none; b=JmZ7Shk8EeU6psOlVZsRPzDGXmUoAtst9l7xmiSBpJH2VVCxBjn1bpzJ/s9uf1kt/yQB3J 6f0Fyfo8fmQ62P6qY/3c3oHbb1Dmi2mhDgy8ukvuMWAXEtUav6ZJYD5czTrk6Ys8d0nHS8 P8PuonD/Ov8wxmAKY+6gNFb+Ek71CHE= Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4281faefea9so17592675e9.2 for <linux-mm@kvack.org>; Fri, 16 Aug 2024 17:18:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723853917; x=1724458717; darn=kvack.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=FURCjfhnzhcGGezKZU8awwiF5O22NwDdSRjockESBWM=; b=BttZK01/d+VE3QJqgf0I6ouQyevKhkuzlFerfRAaJwJ4BZ6/E3Oc7IuygGdR21fQFw fpewZFQXleH2Z4O/2xrNuOX5PK8UU9TqbqvRDXbrW0vzIzZTbyKJkGb6TqqHKZgu13Qf 6I0L8BxMIg1hMf5t8jgl4zdwWqqv7kloUV2hivDy5FLu4QlmPE8qNRlmam3D2MfR5AlV SKYntlNS8Re9mbNJ0q0hW2lHEUJiVz7FiLFQrl29eq1XwhVpy1/wMS/6aC8CXKG3s4Xb SNcx6nQk4beJk2uDhWa8fTJ8UfE6JbqdHwF+t12Kg1ruY2XgWMPaznHTRlDNDhm1/r9B pbTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723853917; x=1724458717; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FURCjfhnzhcGGezKZU8awwiF5O22NwDdSRjockESBWM=; b=sJkqlFBmhgMmIcRpF04V26REnJ1WFDsWMXEf3pcSUtDLqzYa4eltkYVIjDrrJk/GFs S76UlmbhjWGbuI8/o37lPrswoXJiQwE/gmWv7OLDmWTcXrYUIEc5xHc6Q1z2JXJ1VWzc tgbhFlyLuqWPxJuxlHDE+1je8potF+jV+lLSzNKn06mvN5jx2Dv/GE028sPOOLt0lBrK 2ce3NHTaaYSlT4JdoOK6nlUYytV9wAwE0cogh9IJt5wdkcxzJTyl4yLqpFp9kYFTcNIx dm/mBlPpqDpIM/JijiQGs1KcCosQecpsIrIqInBtoFJx0D1RsonImrblvtq4LUi9RZrS rZ9w== X-Gm-Message-State: AOJu0YxfMch4qSq0oy5tizCjZk4omtLxaoApVAAvdRY5LK+SI+27XmQL aO5HBLn7uD0voR8wFC2d2AIJXMGldHlXpY8XEVNWsCBqQ2J2kKEH X-Google-Smtp-Source: AGHT+IFf2S4c4JqR9lrs6zCGZE0Bs81QFLoFc10b65Dvw+kBaOCfyiQAmdWl+vnO7F2nO3D1XzBcmA== X-Received: by 2002:a05:600c:19cf:b0:425:7974:2266 with SMTP id 5b1f17b1804b1-429ed7cc5dcmr30748785e9.24.1723853916328; Fri, 16 Aug 2024 17:18:36 -0700 (PDT) Received: from [192.168.1.91] ([2001:818:e92f:6400:96b:aa92:afc0:2d3d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d781047asm104842055e9.0.2024.08.16.17.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 17:18:35 -0700 (PDT) From: Pedro Falcato <pedro.falcato@gmail.com> Subject: [PATCH v3 0/7] mm: Optimize mseal checks Date: Sat, 17 Aug 2024 01:18:27 +0100 Message-Id: <20240817-mseal-depessimize-v3-0-d8d2e037df30@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAFPsv2YC/x3MSwqAIBRG4a3EHSeYRlRbiQahv3WhF16ISNp70 vAbnJNIEBlCfZEo4mLhY8+wZUFumfYZin02GW1q3VaN2gTTqjxOiPDGD1Swne9C7axxDeXujAh 8/89hfN8PJcmTxmMAAAA= To: Andrew Morton <akpm@linux-foundation.org>, "Liam R. Howlett" <Liam.Howlett@oracle.com>, Vlastimil Babka <vbabka@suse.cz>, Lorenzo Stoakes <lorenzo.stoakes@oracle.com>, Shuah Khan <shuah@kernel.org> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, jeffxu@chromium.org, oliver.sang@intel.com, torvalds@linux-foundation.org, Michael Ellerman <mpe@ellerman.id.au>, Kees Cook <kees@kernel.org>, Pedro Falcato <pedro.falcato@gmail.com> X-Mailer: b4 0.14.1 X-Stat-Signature: znagq76u5eb7kmjnxkuiys6yucmart7g X-Rspam-User: X-Rspamd-Queue-Id: 020EEA0006 X-Rspamd-Server: rspam02 X-HE-Tag: 1723853918-151866 X-HE-Meta: U2FsdGVkX1/2+efrkowYTSSCsaGWlZ8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Z5MqglCix/OJSsNIBoBYD0ZmEMQBvk3Dt6DgaI4VI/B6bRLZoeLZSTfKkP2H0LPhSbWYbV9YNCI8G0xeZ0J1VU6cskV3KHZNr3N6lH1Zht+gl8rKqzrdLpGxHgnWBUkGuzGYZjg7JwsGTmH/Sf9JG8O/1QMoIHrYmb7jui1kV7DDU3B3S+gMqEPLn3+VEt68tlWeIGSiXjZYYY4KP7kDelrq4ju97lk5LrbjTOvkNSj8w464cXPLn94+nYPGoTVAwmAu/hz3XfbCRX+hmv80jyz4ndTVAGqq4nWgLaPF7O0T2NtYZjdSFAkPplqCHXlBJSS1hWVLmLcSlFk4DhgIxwN+LF9gBCnhwu844JMyVg/DrERI/g+Q0W/tKciUrZnooA4qrneL4zFfobxKUreywsh6upAvSlWhMO9UWTYpjD+S++OuSNBA/jmyzY= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm: Optimize mseal checks
|
expand
|
[based on mm-unstable, 651c8c1d7359] Optimize mseal checks by removing the separate can_modify_mm() step, and just doing checks on the individual vmas, when various operations are themselves iterating through the tree. This provides a nice speedup and restores performance parity with pre-mseal[3]. This series also depends on the powerpc series that removes arch_unmap[2]. This series is already in mm-unstable. will-it-scale mmap1_process[1] -t 1 results: commit 3450fe2b574b4345e4296ccae395149e1a357fee: min:277605 max:277605 total:277605 min:281784 max:281784 total:281784 min:277238 max:277238 total:277238 min:281761 max:281761 total:281761 min:274279 max:274279 total:274279 min:254854 max:254854 total:254854 measurement min:269143 max:269143 total:269143 min:270454 max:270454 total:270454 min:243523 max:243523 total:243523 min:251148 max:251148 total:251148 min:209669 max:209669 total:209669 min:190426 max:190426 total:190426 min:231219 max:231219 total:231219 min:275364 max:275364 total:275364 min:266540 max:266540 total:266540 min:242572 max:242572 total:242572 min:284469 max:284469 total:284469 min:278882 max:278882 total:278882 min:283269 max:283269 total:283269 min:281204 max:281204 total:281204 After this patch set: min:280580 max:280580 total:280580 min:290514 max:290514 total:290514 min:291006 max:291006 total:291006 min:290352 max:290352 total:290352 min:294582 max:294582 total:294582 min:293075 max:293075 total:293075 measurement min:295613 max:295613 total:295613 min:294070 max:294070 total:294070 min:293193 max:293193 total:293193 min:291631 max:291631 total:291631 min:295278 max:295278 total:295278 min:293782 max:293782 total:293782 min:290361 max:290361 total:290361 min:294517 max:294517 total:294517 min:293750 max:293750 total:293750 min:293572 max:293572 total:293572 min:295239 max:295239 total:295239 min:292932 max:292932 total:292932 min:293319 max:293319 total:293319 min:294954 max:294954 total:294954 This was a Completely Unscientific test but seems to show there were around 5-10% gains on ops per second. Oliver performed his own tests and showed[3] a similar ~5% gain in them. [1]: mmap1_process does mmap and munmap in a loop. I didn't bother testing multithreading cases. [2]: https://lore.kernel.org/all/20240807124103.85644-1-mpe@ellerman.id.au/ [3]: https://lore.kernel.org/all/ZrMMJfe9aXSWxJz6@xsang-OptiPlex-9020/ Link: https://lore.kernel.org/all/202408041602.caa0372-oliver.sang@intel.com/ Changes in v3: - Moved can_modify_vma to vma.h instead of internal.h (Lorenzo) - Fixed a bug in munmap where we used the wrong VMA pointer - Added tests for the previous munmap bug - Moved the mremap source vma check upwards, to stop us from unmapping dest while the source is sealed (Liam) Changes in v2: - Rebased on top of mm-unstable - Removed a superfluous check in mremap (Jeff Xu) Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> --- Pedro Falcato (7): mm: Move can_modify_vma to mm/vma.h mm/munmap: Replace can_modify_mm with can_modify_vma mm/mprotect: Replace can_modify_mm with can_modify_vma mm/mremap: Replace can_modify_mm with can_modify_vma mseal: Replace can_modify_mm_madv with a vma variant mm: Remove can_modify_mm() selftests/mm: add more mseal traversal tests mm/internal.h | 16 ----- mm/madvise.c | 13 +--- mm/mmap.c | 11 +--- mm/mprotect.c | 12 +--- mm/mremap.c | 32 ++------- mm/mseal.c | 55 ++-------------- mm/vma.c | 19 ++++-- mm/vma.h | 35 ++++++++++ tools/testing/selftests/mm/mseal_test.c | 111 +++++++++++++++++++++++++++++++- 9 files changed, 174 insertions(+), 130 deletions(-) --- base-commit: 651c8c1d735983040bec4f71d0e2e690f3c0fc2d change-id: 20240816-mseal-depessimize-f39d9f4c32c6 Best regards,