From patchwork Tue Nov 19 11:24:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdiel Janulgue X-Patchwork-Id: 13879744 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 F3A0BD44145 for ; Tue, 19 Nov 2024 11:24:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6233C6B009A; Tue, 19 Nov 2024 06:24:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D29F6B009C; Tue, 19 Nov 2024 06:24:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49B016B009D; Tue, 19 Nov 2024 06:24:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2C8196B009A for ; Tue, 19 Nov 2024 06:24:41 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A35491A034E for ; Tue, 19 Nov 2024 11:24:40 +0000 (UTC) X-FDA: 82802610324.21.C63AF6A Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by imf16.hostedemail.com (Postfix) with ESMTP id DD780180010 for ; Tue, 19 Nov 2024 11:23:48 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=S5jDcKwK; spf=pass (imf16.hostedemail.com: domain of abdiel.janulgue@gmail.com designates 209.85.167.46 as permitted sender) smtp.mailfrom=abdiel.janulgue@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=1732015235; 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=07UtVhho8S0D2lzIwJjoCBta99cPoEpopuv+zk6Kseg=; b=samncAAXPWr7PIB71gQ8utm5SzhXs9VtTTlthRZ29x3di/IaIKTwSYydrOITISYtfbjWfg ChbFuyzg8rfzs2ZZqPEd1zgmo3rR9R29zU6+yvMW/fWmghdkGIrmnhLJq5WlkD0zSQH4ZX yHreXytGJjNBfn+gpML5EvcrbETLrtA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=S5jDcKwK; spf=pass (imf16.hostedemail.com: domain of abdiel.janulgue@gmail.com designates 209.85.167.46 as permitted sender) smtp.mailfrom=abdiel.janulgue@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732015235; a=rsa-sha256; cv=none; b=nDfoNDLXPEocYqXviLjk5+4cA4rF7bhg0HNPvjhaziejrTMBbxJQ4xO/bkcHNuKE1lT5n8 dzsh4md+d0+l3sqJ9YX5e6QagclYvSWJ3artc5jiuBDVwR/D31IVQGvDun3XPJDUvzClTz A8SLIXVWhGw9q5BFZEs3CsK3YioIXsc= Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-53a007743e7so4627107e87.1 for ; Tue, 19 Nov 2024 03:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732015477; x=1732620277; 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=07UtVhho8S0D2lzIwJjoCBta99cPoEpopuv+zk6Kseg=; b=S5jDcKwKRyqNMD3LpXRB1s7geF0zhzhiJGXvmr58pzq2TUKCOIvyf0xO+tClNsP2J7 fqFnFtRp2fkIguAazTDfI9eR1t0zmVyYYk+g4QxPPCRDfffZn/ifMxkt0YMdf04fugZ+ nVZWJZDVCDdxFG7KBFEw02n2NXseFQwNgKbGiJmNOWiynFNsAYlH1jXfn9fAhq+R+9lp RJiQZN0SPmVZlvU0Utr2ihpAsOAqFJXmvUNV4SYCReygSi+5V2SHa7GLk5ure8YhnrbE RsqzCcprd42RKbfpIe4QA4EDCzrfiondWppVF+vDbPKjOrIiPVIGVVZ8CejhQCZEjxlW PK/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732015477; x=1732620277; 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=07UtVhho8S0D2lzIwJjoCBta99cPoEpopuv+zk6Kseg=; b=KTYe5R9FRVP+3j9m12TV3G11q7edYhVY7U+hYR5ssT69LdoEdh930C3IozsmW4fjUj zDmRE52xVvK0IGVkdpxzXEFmSw5pKF2boAtKdsNfuIJOTP6nL6vVbIZ2QNtbERN9J3XR TzEai4TWSgy6VMac1OJJaxe6ppc5KEVLEtocfTGVFmU3xegpgiBrSq9N0XkUea9JqugH 3PlkKOhrwuGC6r/z9efJZ7ULN6yzrTtRWwl2k5UNglWLqEyBnmoDtPpSYbyBFvgsckye NoAp/fkiRi9U1qzk6OqdK2uXdfI387EY60tqGF5In/K3z2aifGYWnkhf7H+hnsSQwSd8 r5pQ== X-Forwarded-Encrypted: i=1; AJvYcCVS5FZgOL4vWohn/E0NGig3lhqy9duXl+w1fx93ghvCQzKlyTGmpA77CxNb7WMuxlCKaVybPQLpIw==@kvack.org X-Gm-Message-State: AOJu0YxhgiDd1qEh+f6Q5qQETvkcId5K1v2L895adZDti2I1L8EPudoj MHVNsTQ/t0dSL3EmFxj37tClHfsNkoqtmbu5DyNbS2aOrzs3aRFb X-Google-Smtp-Source: AGHT+IFEwgH/qQqqDW3K0M0FjTVj+zPROO31piqFvXey9OYFgWbWJSTuDaFf+mL2sb7FYhUVnuzmtA== X-Received: by 2002:a05:6512:3c83:b0:539:e94d:2d3d with SMTP id 2adb3069b0e04-53dab295fa3mr7165890e87.7.1732015476785; Tue, 19 Nov 2024 03:24:36 -0800 (PST) Received: from abj-NUC9VXQNX.. (87-94-132-183.rev.dnainternet.fi. [87.94.132.183]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53dbd478279sm271899e87.232.2024.11.19.03.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 03:24:35 -0800 (PST) From: Abdiel Janulgue To: rust-for-linux@vger.kernel.org Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?B?= =?utf-8?q?j=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Wedson Almeida Filho , Valentin Obst , linux-kernel@vger.kernel.org (open list), Andrew Morton , linux-mm@kvack.org (open list:MEMORY MANAGEMENT), airlied@redhat.com, Abdiel Janulgue Subject: [PATCH v3 0/2] rust: page: Add support for existing struct page mappings Date: Tue, 19 Nov 2024 13:24:01 +0200 Message-ID: <20241119112408.779243-1-abdiel.janulgue@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: DD780180010 X-Stat-Signature: aah9gk1hhphek9ik8wpunp4gr1cgf391 X-Rspam-User: X-HE-Tag: 1732015428-996864 X-HE-Meta: U2FsdGVkX1+Po+lza75kBwpoApJZM1fl9ei9r0sxLq33M7e/2A6jslkV1pZlqFFvUeX91Fx+WJhsuhfSuSUh0zIk6NhhtP37CmsSA621UGbNmoDFxplKWeV6gjU1EMiu1OfNx5Q/nZCI3Ez0oXCTzMECX1s/kxXhgIDDVtJTJ7h2IxOcNW9z1C3WLw1iErf3o3X4OIgaz86aG+JtEsXkXTGR+k/tDVUfNrYd8I7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ZNIjhp7v7UaQ9zT2YcmM7oXFJXudu4mskUD0Z8l1/NYUy44QxP/oDgruI0s+Q751CbCUhXZsesMAA8iOmnxdHPL2grxiziYAWKf5J7Hlfr31zg5Z8NAmsSywzJaMqaYRKcvPJPRUl1t5ASVHq8IYg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000122, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This series aims to add support for pages that are not constructed by an instance of the rust Page abstraction, for example those returned by vmalloc_to_page() or virt_to_page(). Changes sinve v3: - Use the struct page's reference count to decide when to free the allocation (Alice Ryhl, Boqun Feng). - Make Page::page_slice_to_page handle virt_to_page cases as well (Danilo Krummrich). - Link to v2: https://lore.kernel.org/lkml/20241022224832.1505432-1-abdiel.janulgue@gmail.com/ Changes since v2: - Use Owned and Ownable types for constructing Page as suggested in instad of using ptr::read(). - Link to v1: https://lore.kernel.org/rust-for-linux/20241007202752.3096472-1-abdiel.janulgue@gmail.com/ Abdiel Janulgue (2): rust: page: use the page's reference count to decide when to free the allocation rust: page: Extend support to existing struct page mappings rust/bindings/bindings_helper.h | 1 + rust/helpers/page.c | 20 +++++ rust/kernel/page.rs | 135 ++++++++++++++++++++++++++++---- 3 files changed, 142 insertions(+), 14 deletions(-) base-commit: b2603f8ac8217bc59f5c7f248ac248423b9b99cb