From patchwork Mon Sep 18 20:18:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 13390392 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 A1255CD37B0 for ; Mon, 18 Sep 2023 20:18:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0CA86B044F; Mon, 18 Sep 2023 16:18:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBCC26B0450; Mon, 18 Sep 2023 16:18:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A849B6B0451; Mon, 18 Sep 2023 16:18:50 -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 989E86B044F for ; Mon, 18 Sep 2023 16:18:50 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4DC03C030A for ; Mon, 18 Sep 2023 20:18:50 +0000 (UTC) X-FDA: 81250831620.06.5592484 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by imf07.hostedemail.com (Postfix) with ESMTP id 872194002A for ; Mon, 18 Sep 2023 20:18:48 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=BvTJR2eZ; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of jannh@google.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=jannh@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695068328; a=rsa-sha256; cv=none; b=17B82pzyEeGbd6cIxvkNkOIptymruDSkYxn4ij8sEA2HfC1Uu/CgcSZEJNbS6wC8gjW0y/ 1PFS94Sf58jsKcoxPdn959tfrsf/24bQlYkx/2jwAY69YCyBPEixnaMhLBxLc8AEL60k2Y nh5MPdGJVWOxMI2BYa5jIYq7AVnK654= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=BvTJR2eZ; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of jannh@google.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=jannh@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695068328; 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:references:dkim-signature; bh=gkkuj5E4x1e6TpkXqhUiBmxr9QkX14PDo84XKtGvNno=; b=RdtKOXk9TjsCSZZz3nMdkb6obUfuE4w8HNxJoSRV+TeFNCtFbeVaHVQLfhGk54ZH8k93co XXHpgGot6PaT3ACASSzzPpJFNRbI1dza4xsiYnZRxJPCcRAiyBZaZ/i+QR28EPr/ZovrIo AL0qI0djBLwU8S1/6xLLUGbpw9xczfo= Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4047c6ec21dso23105e9.0 for ; Mon, 18 Sep 2023 13:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695068327; x=1695673127; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gkkuj5E4x1e6TpkXqhUiBmxr9QkX14PDo84XKtGvNno=; b=BvTJR2eZPNT3dTLX1DSMmofFCBEcgHtrQBtFo3gse7vYQsifWP7Wnw19eaAFaYX/Nf NezhCR9HT8EamsMLA2ERgPFq3su6Sno82u7sumgPqf8JD6iU1Ya3tzx8xZ910V7OE29E /K7iYDAmhwyHG7r2/d3zxAlX2XOBEN8y9T0+leQUPY27XTBAl0rv2r0QS3b69P+qmeaV QfcXb7nMX2nqj2vg/ZDpWjeW4Ryu9jbq7rJMUMKw1viTfTBnH70TBl/FHB/4ccxgJ0PC 9mtcwCaxDD5QmsEA5aDcDCZ7J37m/ffUIaUhppP8J+yTspsq4mCtD4yq5rWyf1HUa0+u a8SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695068327; x=1695673127; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gkkuj5E4x1e6TpkXqhUiBmxr9QkX14PDo84XKtGvNno=; b=vjHNxWrHxe3fVrzQm9u3/yhFyGMFNU7GnvwlcgE3vq6AbT8jgnvKp63R+w0wTkXnez dc5Igl7HL1IaNaZB/GhphoFj5rtFt8jyqynMFbTwTUkmXa2Awgpv6AkYEeOvD+uzJ0gN xg34RkqZEGdFhVRLwrKF6Um5A5Qzv1zdZGhzX8WF6JHi61fln41Bz1gZtTMxbdoD2H+D +hz8LJvUXodIxyZ2wZsjZMKw6aw71WLUw/dF+BGhrHXoxh/DW18nMcaHP5kZYLxj7wL1 etJFP/foOeK+vPpfLUt3wU4mr49trvU3nf1YNNHC9jCyhk/utuGLPw+ia4JCZ94b4BF7 GCQg== X-Gm-Message-State: AOJu0YyIU5uQ3osCa2w8NEzEoMhit31PIFiAPtuK8rtfI6ozr2n6lmMf IIA1oWTDLiIIkA1bpFa2+aE9QA== X-Google-Smtp-Source: AGHT+IFPfXjLQWY+XTrivjGyq5y6EUdbaEOdn9f05wDcTfA1C8e0Gf41avxSx5fLPuTL4g/18veJ1w== X-Received: by 2002:a05:600c:4fd6:b0:3fe:ef25:8b86 with SMTP id o22-20020a05600c4fd600b003feef258b86mr22708wmq.4.1695068326889; Mon, 18 Sep 2023 13:18:46 -0700 (PDT) Received: from localhost ([2a00:79e0:9d:4:2d2b:53ca:9e7d:d91b]) by smtp.gmail.com with ESMTPSA id a4-20020a5d4d44000000b00317e77106dbsm13372719wru.48.2023.09.18.13.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 13:18:43 -0700 (PDT) From: Jann Horn To: Andrew Morton Cc: Alistair Popple , Jason Gunthorpe , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] mm: document mmu_notifier_invalidate_range_start_nonblock() Date: Mon, 18 Sep 2023 22:18:32 +0200 Message-ID: <20230918201832.265108-1-jannh@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 872194002A X-Stat-Signature: 7ej84c9smacqaim1qctuhnp1bz96r53c X-HE-Tag: 1695068328-261974 X-HE-Meta: U2FsdGVkX18cGj/DwncWC5x/1EomOg3EqMCTKkIGEmo+yXGSJJdpA74nYTKOpL8XGs7jABxDj7dKyVV8YRsOuW4WksLehOHb0bzHtPQjqGUX6d6sgZgOMDP0D9bVhf/r/d2Eu1McX8/6/oH6LZlXyje+hgbTJrllI9WEdDyAzFWJrcUHF1VZeAbOvTGK2bbqCIBUH7rA2aGtESPMePB9jpLMlbQoq+mxmzL1ILhzlotksqJCep8L0urQSUct5MNPsKkgzUfwiomxR3FBr2z/zBpg6KSh1hdo53LBSS3gX00yLihLV02wMYalFFW/VSimmDdGI1zkLlxicB9CnQsmdry3Uz5/12AScumGj/JnMviNGd4kvd7RYAZMq3QqguxH3fW4rlfTZcERFsSrdqDLqUVM4Z1pG9BbaC23UZi5ZsBwNnAGof7OeaO5ZmRF1hrPcMhguip735QTzdwR6C+pjv2QA9NhOWKUJU/pgPZGyxaPei42DeNTiF3RJgMrnFBrM17p6libvFK/wBat1AS4woG9yp1+2A7pzkU5zAI9AYr19xJYs7o9nNaVdWytT0pOfuaUMaZyZkqm1+/n92TMRFC376f+gs2FvXFzKjCOKxH5VD003umu4fzvWP6KJA1etW7TfzNoMbGSjteaOZZBzqdlUk5vmwEbOFDBdurkKZDm1zOnr6a5UZRzihRvDTmRcvEZioiIfNV9debHM88cB3CS8quNNKifdviCma7e114rqEXuu2ImKq3kJ15+9wT3FH66P9QvWh4d/0OfwA/BU2oDvdcI0Cxx8kTFOC8w5jLtSt8stMPkRyxV+ePkV4dgZABwwSl2vzwys4nZrXh2xwrx0wPNd0H8NreHk1akuKUX76yLpVJwJPN/92bZx4fW9hX4ZKGr16xUgZyCy1NyMwXjjGwIp+4YlT9UaiZRadEO7K2PqBDD56Bal4nNvPxQp5hOWPhguW8Z+Sv5BO4 nUVB7soj VfIlyV2eVNHAaW5VjMkEi6DgbOlVMiPI69TKuTKjIbRAZKJNRDSt4dbLAV17gI32DjNxr8A5IKCJYHHgQmHG7SIo8VzgaDINTMlrXQYSxMU0vEljbNfaxce1i8+K0BeA/dF5dqwar6F4n2MUShLD2r+VURHb/zuyH+9MCFITqtNsR2aSH3OnLsoWi5nAfekIMQh0to/Fs53SAh4FmRunKTcsppZegrCzuM07x4pihTmznnmToofJXoaxP79G1cniDAcbZ8NQ32RBF4ADtC68k6FZSILjnw+LJTBl+x6Ictd1o2Ofrif0mKMEKgzZ/JtzLfu2syCI0hsZpXKaoG02VjBwHYkwEnHVNtZgXAAoqWnMJvCibxLWgJhCJ5sgppSiBhl5Qn+dRX2tABziQl6m3X3l2Q7yDa5PQa/4MtR59U7i8D18= 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: Document what mmu_notifier_invalidate_range_start_nonblock() is for. Also add a __must_check annotation to signal that callers must bail out if a notifier vetoes the operation. Signed-off-by: Jann Horn Reviewed-by: Jason Gunthorpe Reviewed-by: Alistair Popple Reviewed-by: David Hildenbrand --- include/linux/mmu_notifier.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) base-commit: 6704c78e2963a5682b4ac3c0e609d36f2405cf17 diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 6e3c857606f1..f349e08a9dfe 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -459,7 +459,14 @@ mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) lock_map_release(&__mmu_notifier_invalidate_range_start_map); } -static inline int +/* + * This version of mmu_notifier_invalidate_range_start() avoids blocking, but it + * can return an error if a notifier can't proceed without blocking, in which + * case you're not allowed to modify PTEs in the specified range. + * + * This is mainly intended for OOM handling. + */ +static inline int __must_check mmu_notifier_invalidate_range_start_nonblock(struct mmu_notifier_range *range) { int ret = 0;