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 4CDEDC4345F for ; Thu, 18 Apr 2024 20:19:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D94716B00A5; Thu, 18 Apr 2024 16:19:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D44AF6B00A7; Thu, 18 Apr 2024 16:19:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE5626B00A9; Thu, 18 Apr 2024 16:19:40 -0400 (EDT) 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 98DDB6B00A5 for ; Thu, 18 Apr 2024 16:19:40 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7DEF31A1198 for ; Thu, 18 Apr 2024 20:19:38 +0000 (UTC) X-FDA: 82023768036.27.D10BFA1 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by imf05.hostedemail.com (Postfix) with ESMTP id B9F8B100014 for ; Thu, 18 Apr 2024 20:19:36 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=I4lnhrYC; spf=pass (imf05.hostedemail.com: domain of surenb@google.com designates 209.85.128.181 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713471576; 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=U8QBUU5Ysvq0j9xQzigQOcx89V1FF41qSoo2aFaccrc=; b=2JyX+Sdp8eKHbVD6P7GKDTbCF6sR4hWqY1z5gdFhtjtWR79Ih7RyEZ8z7ASPECHYhmUXMb dIWkJsjd74jm7Yp3Ok6h41eKSzqfzdLUOQnJhWBQ/72HX/5l02a3hwVzaBWxmdg5FNp88h ZtBRHG1aj/pNV+3O3kn9KfLo0V5ZWMM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=I4lnhrYC; spf=pass (imf05.hostedemail.com: domain of surenb@google.com designates 209.85.128.181 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713471576; a=rsa-sha256; cv=none; b=voyQh/K9zvuUGclYEXHbkhRae+LVGXQQ5L1eEXPZJ9VhzBAsW5fGbtE4DXR5gnECg9J1Og /WypyyTlvveT2K7joJD/QKN+NzXUMzQ3puFeiImVmwB4e7naWoskvq2+k3mlRnbq+aUXzb ImdVJ2WtfKT6F4Y5cfx37FaBhZEsbUk= Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-615019cd427so12041937b3.3 for ; Thu, 18 Apr 2024 13:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713471575; x=1714076375; 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=U8QBUU5Ysvq0j9xQzigQOcx89V1FF41qSoo2aFaccrc=; b=I4lnhrYCsvWX/nP+jv83TCuuyr0QNgooepvIK7QIB5tnBta7llEaLFHgrxAGhT9p40 DX+iUjMBrMf35l4XRziMY4zTBRRrbxxic2dRb2S5FFZ3r7YbvUxlpYpEZ0t9J2eqbRsO s+JZCFw33C+w2Ojgx6/aB3Z3wQcYzWS1Sn0v7Eh5SJqutWg3c5KvGXqdLRKwL6kXtlJA oFfmBnyHjPXBTRRHvvzm0si8mtvpdBJJzVVRuHVDl8IgELApUgNsQT5GL6L1dlwboPMx 7ZArfuM/diZ7nBneQdRWcNzUW8QvI4w0Z0J7DyTGaUEHFz29WnqHyN1ZOWo3s2LRAgtT kTNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713471575; x=1714076375; 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=U8QBUU5Ysvq0j9xQzigQOcx89V1FF41qSoo2aFaccrc=; b=gWmLPn47CDJQazM3P8TIdMQrcTmfINLBt9/8FVKzw3V3vaCO1r+XUrR9NN588t/mcy faqqhPftlAs/fobQliob8jRrDeHkob6ShbeeJjbn/prcxb+Q4dyLZlhl8iDuhf9ujpDt TWeCC/DhEUKwp+Wp0dsttecO//BUFs0bZE8fL4eTnDQKrp2vUn55e4/sxzANBJgG4mFf Xz0FXJH6oNS/Vku/yxtgVWYCKiaiYHOA4lFD2pRCavGaCq1qwXP3xnIcbyVCJxl1qh8K asmi7J2f5VY2L6TZFK62tgXyepB8uC8WJJAWmn8MZOF0CJplp8oH3d/AhJyBtimIYx7L c9/A== X-Forwarded-Encrypted: i=1; AJvYcCWPrKncDFnWRwJrP3Fto1izprE+Dbfipu5i2p51Y8yr1g5dVIVXxd+IR1F+RnLyy4mSFfAlkt9BU0QnZWOgPexZo6E= X-Gm-Message-State: AOJu0YxTDpEQ4QBHZ+zLQBn8O/twtuYMu2jT7CuLnP+0AuGLpHjYgd9F NZLUwy1bwxgXZVxI1ui3o+/9olhIyAy8dOdGJMJ95VTvPQe/53B+DLcO/VI4bCrqCS7y2MH7JgK wx1UTTdQiHZnthjA3EBfRk7QTZw9kRpFYH0OH X-Google-Smtp-Source: AGHT+IGu9bLqHeW4a7VwQv2rIIJwjvvl2bf1vYPr5n5skx61Fk0UUEN3VzUE36VDByjHyx19HwGN1Ahow7j5FwTcF2I= X-Received: by 2002:a25:bad1:0:b0:dc7:4bab:c390 with SMTP id a17-20020a25bad1000000b00dc74babc390mr3618530ybk.61.1713471574368; Thu, 18 Apr 2024 13:19:34 -0700 (PDT) MIME-Version: 1.0 References: <20240415163527.626541-1-jeffxu@chromium.org> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 18 Apr 2024 13:19:23 -0700 Message-ID: Subject: Re: [PATCH v10 0/5] Introduce mseal To: Jeff Xu Cc: "Liam R. Howlett" , akpm@linux-foundation.org, keescook@chromium.org, jannh@google.com, sroettger@google.com, willy@infradead.org, gregkh@linuxfoundation.org, torvalds@linux-foundation.org, usama.anjum@collabora.com, corbet@lwn.net, merimus@google.com, rdunlap@infradead.org, jeffxu@google.com, jorgelo@chromium.org, groeck@chromium.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, pedro.falcato@gmail.com, dave.hansen@intel.com, linux-hardening@vger.kernel.org, deraadt@openbsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: qir3qdgwd4fbmhabw5q7i68z46xs44on X-Rspamd-Queue-Id: B9F8B100014 X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1713471576-139793 X-HE-Meta: U2FsdGVkX1+Jj18kRiao/R38iexI5kSvtekHVP2+lmgyZs0QXYOCkqIXVxtH+9M+cElIL9oZ8IeuUcXzd3PkK0hnPYqaz6iOFAzossT6umttfxw4MoWID6BBkzv+uihCNW8m1da+jrtcca4gTSfpn7hs38nj5f4txj+ngnvQ/yWcUJdIzDFgVtr0NUSI+EkVcUTPTLBS3GF4nPyAEAvyQ9aEMs3Jsihl18RZMB0lgHDQF2BNbnrUIm7Lgu4vokLEAHPz3NlmdUQLZ26QoDcIe2PlqKWRvika2cxaDtrQfAdHyMMLMddFIbzp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, 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 Tue, Apr 16, 2024 at 12:40=E2=80=AFPM Jeff Xu wrot= e: > > On Tue, Apr 16, 2024 at 8:13=E2=80=AFAM Liam R. Howlett wrote: > > > > * jeffxu@chromium.org [240415 12:35]: > > > From: Jeff Xu > > > > > > This is V10 version, it rebases v9 patch to 6.9.rc3. > > > We also applied and tested mseal() in chrome and chromebook. > > > > > > ------------------------------------------------------------------ > > ... > > > > > MM perf benchmarks > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > This patch adds a loop in the mprotect/munmap/madvise(DONTNEED) to > > > check the VMAs=E2=80=99 sealing flag, so that no partial update can b= e made, > > > when any segment within the given memory range is sealed. > > > > > > To measure the performance impact of this loop, two tests are develop= ed. > > > [8] > > > > > > The first is measuring the time taken for a particular system call, > > > by using clock_gettime(CLOCK_MONOTONIC). The second is using > > > PERF_COUNT_HW_REF_CPU_CYCLES (exclude user space). Both tests have > > > similar results. > > > > > > The tests have roughly below sequence: > > > for (i =3D 0; i < 1000, i++) > > > create 1000 mappings (1 page per VMA) > > > start the sampling > > > for (j =3D 0; j < 1000, j++) > > > mprotect one mapping > > > stop and save the sample > > > delete 1000 mappings > > > calculates all samples. > > > > > > Thank you for doing this performance testing. > > > > > > > > Below tests are performed on Intel(R) Pentium(R) Gold 7505 @ 2.00GHz, > > > 4G memory, Chromebook. > > > > > > Based on the latest upstream code: > > > The first test (measuring time) > > > syscall__ vmas t t_mseal delta_ns per_vma % > > > munmap__ 1 909 944 35 35 104% > > > munmap__ 2 1398 1502 104 52 107% > > > munmap__ 4 2444 2594 149 37 106% > > > munmap__ 8 4029 4323 293 37 107% > > > munmap__ 16 6647 6935 288 18 104% > > > munmap__ 32 11811 12398 587 18 105% > > > mprotect 1 439 465 26 26 106% > > > mprotect 2 1659 1745 86 43 105% > > > mprotect 4 3747 3889 142 36 104% > > > mprotect 8 6755 6969 215 27 103% > > > mprotect 16 13748 14144 396 25 103% > > > mprotect 32 27827 28969 1142 36 104% > > > madvise_ 1 240 262 22 22 109% > > > madvise_ 2 366 442 76 38 121% > > > madvise_ 4 623 751 128 32 121% > > > madvise_ 8 1110 1324 215 27 119% > > > madvise_ 16 2127 2451 324 20 115% > > > madvise_ 32 4109 4642 534 17 113% > > > > > > The second test (measuring cpu cycle) > > > syscall__ vmas cpu cmseal delta_cpu per_vma % > > > munmap__ 1 1790 1890 100 100 106% > > > munmap__ 2 2819 3033 214 107 108% > > > munmap__ 4 4959 5271 312 78 106% > > > munmap__ 8 8262 8745 483 60 106% > > > munmap__ 16 13099 14116 1017 64 108% > > > munmap__ 32 23221 24785 1565 49 107% > > > mprotect 1 906 967 62 62 107% > > > mprotect 2 3019 3203 184 92 106% > > > mprotect 4 6149 6569 420 105 107% > > > mprotect 8 9978 10524 545 68 105% > > > mprotect 16 20448 21427 979 61 105% > > > mprotect 32 40972 42935 1963 61 105% > > > madvise_ 1 434 497 63 63 115% > > > madvise_ 2 752 899 147 74 120% > > > madvise_ 4 1313 1513 200 50 115% > > > madvise_ 8 2271 2627 356 44 116% > > > madvise_ 16 4312 4883 571 36 113% > > > madvise_ 32 8376 9319 943 29 111% > > > > > > > If I am reading this right, madvise() is affected more than the other > > calls? Is that expected or do we need to have a closer look? > > > The madvise() has a bigger percentage (per_vma %), but it also has a > smaller base value (cpu). Sorry, it's unclear to me what the "vmas" column denotes. Is that how many VMAs were created before timing the syscall? If so, then 32 is the max that you show here while you seem to have tested with 1000 VMAs. What is the overhead with 1000 VMAs? My worry is that if the overhead grows linearly with the number of VMAs then the effects will be quite noticeable on Android where an application with a few thousand VMAs is not so unusual. > > -Jeff