From patchwork Sat Aug 17 00:18:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Falcato X-Patchwork-Id: 13766876 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 AA8B8C531DC for ; Sat, 17 Aug 2024 00:18:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFA9F6B018B; Fri, 16 Aug 2024 20:18:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A49776B020E; Fri, 16 Aug 2024 20:18:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 899F96B020F; Fri, 16 Aug 2024 20:18:42 -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 6646C6B018B for ; Fri, 16 Aug 2024 20:18:42 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 14F601A03FC for ; Sat, 17 Aug 2024 00:18:42 +0000 (UTC) X-FDA: 82459826484.10.5C83D5E Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by imf30.hostedemail.com (Postfix) with ESMTP id 38D6B8001B for ; Sat, 17 Aug 2024 00:18:39 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="A3ChME/X"; spf=pass (imf30.hostedemail.com: domain of pedro.falcato@gmail.com designates 209.85.128.45 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=1723853861; 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=eE0tAujU+84Fl5Bml9LnGFFfJTwW8AbGe4iKDNDJLPI=; b=MWvVyzRX195DPFGNJUSClfVXQhx5/EKpyV38Yl0XP4gzXyM3qvcLTUpQ2rSaLpI15cZ7So OUjz8trlct0z6smfnanrfQXlRD7kY0HUIInmXtwxE1gAMl6mIlt21SPE9vxS9M6njv2jp7 6ht2FvYOT5LeElQpYby7qHXw0t76vYo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="A3ChME/X"; spf=pass (imf30.hostedemail.com: domain of pedro.falcato@gmail.com designates 209.85.128.45 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=1723853861; a=rsa-sha256; cv=none; b=StDiFbQ4d3eWSwXN+3AWJ5QphzUTAv7BI16pw/DbYlektEHcHiZvyGuTlUbcaAFWPuD3JV FN3HOW4FRF62Nulqo5vyDiWCxKjeK2PcQC9mhpVT2g0BoQ4IWwe1CqgjixV6Y/4tKMtLy/ sqtVHosBw6Xnx3tlTqgdMeeU2GgLark= Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-428101fa30aso18114545e9.3 for ; Fri, 16 Aug 2024 17:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723853919; x=1724458719; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eE0tAujU+84Fl5Bml9LnGFFfJTwW8AbGe4iKDNDJLPI=; b=A3ChME/Xa42nuOuKyMpSOTj97OOeR0o57KeVB1BEMKMU0QI+k7/sCNDw3gysRHwt1o 27pmSzq4hTRu5Bd8v07x82xa5tb0mAnOwk6SJU22NYlQ/yE29IZKwLfCt0BOVuJEoCbz aWSvPFa9TnR8B10BfHiqQLxqGr+0UoZKjYa+dP20FNxws6g9WywYiwzf4YdLILGlbZ0A z+1qEKiQbTIjaTncpjkPLr4L8LnZihO4PG+I5lLEXi1xUjMU9piXU+x2UaAU5+2B+JV4 kmKr6Tw6Xbrf/BUolUUefqKcFfBcApXM1/7l/ZPHcVw/RSkCk0uEGtdxBILPyHsnNRn4 0nDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723853919; x=1724458719; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eE0tAujU+84Fl5Bml9LnGFFfJTwW8AbGe4iKDNDJLPI=; b=MmenzM7+opT+lMQ0Qm3fQraN5wbHk8KBxl/mlcdQLzY+hKNKN0uc/Jx5xFlAw2QJ63 Os7OkqURwIZ7YOwC5OwrHo4hjWCzpc5ZegEfXpi3zn39zURZ7jc2YCXEj5iHBNq3NXLG RAaN/DQUL/WnvM1qtJGaXRu8GRX9rT3dBJmpcdIBZMUZ/L/ACz0DuJ++CDqZ8EtO8hkC Gqv/2P6E28SUyU4TooR2fsA9rDt+O9UEm+r2vNfWmz72ZovOYd5lFLzN+nDFILEMoe83 vWdOhUcWOtwcPljrzFO+Ul6ynO8ouryM7J8dM32ZQsizZGiKFx5h/AGe7XmgegmPRx8Z enig== X-Gm-Message-State: AOJu0Yyy4NdtDQU6H2ZrBFOOxoWGFEWTsdV/h39Gn/1DplAcd0eb+f20 OSkjVjTeQP2x6t81uu+0yHjPg3RQS+ukVooxQHndZpJL8D/k0nja X-Google-Smtp-Source: AGHT+IH+rZczV1rucrOJegV86RCCzxDjSfxcW+VweSbEmrGCi5wWUt76859GZxn1s0ipCW3cR+tVCA== X-Received: by 2002:a05:6000:a81:b0:368:5bb4:169b with SMTP id ffacd0b85a97d-371943159b6mr2775762f8f.4.1723853917768; Fri, 16 Aug 2024 17:18:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 17:18:37 -0700 (PDT) From: Pedro Falcato Date: Sat, 17 Aug 2024 01:18:28 +0100 Subject: [PATCH v3 1/7] mm: Move can_modify_vma to mm/vma.h MIME-Version: 1.0 Message-Id: <20240817-mseal-depessimize-v3-1-d8d2e037df30@gmail.com> References: <20240817-mseal-depessimize-v3-0-d8d2e037df30@gmail.com> In-Reply-To: <20240817-mseal-depessimize-v3-0-d8d2e037df30@gmail.com> To: Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Shuah Khan 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 , Kees Cook , Pedro Falcato X-Mailer: b4 0.14.1 X-Stat-Signature: otq54a6e7rzw1yh6puxymuwctsocnaya X-Rspam-User: X-Rspamd-Queue-Id: 38D6B8001B X-Rspamd-Server: rspam02 X-HE-Tag: 1723853919-905372 X-HE-Meta: U2FsdGVkX19LulBnKjOcTsqhx1VWG9hIRuWoQWaXqX9kcoiF+oNxQsNZeC9ZYAXYFKKh7QqnMFhFQNh+4Ef81qCa53I3yKw0BaxxCXHzcO4PsKtsEnv1RXYasB5yzsNczZp45ACplmGp3MBd76XCASRDDg6H5NSJZm9zJzbqxST0rb09rIlJu5/XZxba6QZc657IHeMnSn264k3EeO0cURRn7O4EMgBrMw+Cu04MMDoKF08X4qdnWEkY0GlVtk2lqnyQUjyacwba9O57B/M1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p0LUwEzyqnSNGK3gFP8ljjsjAq9h1dVIP+U0bpppY6noGB8xTZx9eP0pPjvB0S/t18EMATmVfAZn+65zg+43YIrQS0t4UCgv9mgb//lO6z/MTxk2FquCBytsu1dwyRU6n/MElupp7T06QrBhQ2iQXNgrUyG1q30= X-Bogosity: Ham, tests=bogofilter, spamicity=0.001109, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Move can_modify_vma to vma.h so it can be inlined properly (with the intent to remove can_modify_mm callsites). Signed-off-by: Pedro Falcato Reviewed-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mseal.c | 17 ----------------- mm/vma.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/mm/mseal.c b/mm/mseal.c index 15bba28acc00..2170e2139ca0 100644 --- a/mm/mseal.c +++ b/mm/mseal.c @@ -16,28 +16,11 @@ #include #include "internal.h" -static inline bool vma_is_sealed(struct vm_area_struct *vma) -{ - return (vma->vm_flags & VM_SEALED); -} - static inline void set_vma_sealed(struct vm_area_struct *vma) { vm_flags_set(vma, VM_SEALED); } -/* - * check if a vma is sealed for modification. - * return true, if modification is allowed. - */ -static bool can_modify_vma(struct vm_area_struct *vma) -{ - if (unlikely(vma_is_sealed(vma))) - return false; - - return true; -} - static bool is_madv_discard(int behavior) { switch (behavior) { diff --git a/mm/vma.h b/mm/vma.h index 6efdf1768a0a..e979015cc7fc 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -361,4 +361,32 @@ struct vm_area_struct *vma_iter_prev_range(struct vma_iterator *vmi) return mas_prev_range(&vmi->mas, 0); } +#ifdef CONFIG_64BIT + +static inline bool vma_is_sealed(struct vm_area_struct *vma) +{ + return (vma->vm_flags & VM_SEALED); +} + +/* + * check if a vma is sealed for modification. + * return true, if modification is allowed. + */ +static inline bool can_modify_vma(struct vm_area_struct *vma) +{ + if (unlikely(vma_is_sealed(vma))) + return false; + + return true; +} + +#else + +static inline bool can_modify_vma(struct vm_area_struct *vma) +{ + return true; +} + +#endif + #endif /* __MM_VMA_H */