From patchwork Wed Mar 26 08:18:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 14029864 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 C0090C3600E for ; Wed, 26 Mar 2025 08:19:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8CF19280065; Wed, 26 Mar 2025 04:19:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 82D58280056; Wed, 26 Mar 2025 04:19:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 682C7280065; Wed, 26 Mar 2025 04:19:06 -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 429CA280056 for ; Wed, 26 Mar 2025 04:19:06 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A764B819CE for ; Wed, 26 Mar 2025 08:19:07 +0000 (UTC) X-FDA: 83263001934.19.2409EE8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 6B505100003 for ; Wed, 26 Mar 2025 08:19:05 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Y9C5snut; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of toke@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=toke@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742977145; 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=BJrq4mLJiJXWNMpizUXhY6u/aCQe+JkhHXm5jj4+P0s=; b=Zc5oQi42nT9d1/8LYzdEZ3DAnfMvavAubwQofaOTPngwf4GDoqMMmJ4roVlhqmeejuOXZQ CrDLlw1si8QeIAvw1XMR1udZT7/MD3V65949vGZD9dio2Q5iWzUVWWT4HoiXsBx0Q8GGpT 9wGsqC09GfxeagKyPhgNrX/tj1nGXxE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Y9C5snut; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of toke@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=toke@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742977145; a=rsa-sha256; cv=none; b=0gX5Bh92nc7NtJiGsTdUaaXStH8KjNHd21gAwa7DsRAbr4T+LRI2W65EON8ZwpIdZWqcA3 OwaPvfIGRStZsvuSIqiZo6HbeU+JxNSpmaJEC82y6nV1TrJreoelaAIi2ZWqb2PW0PB0D9 su6BEFaEAua7B0Q/82YSeQMSCu9zN1E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742977144; h=from:from: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; bh=BJrq4mLJiJXWNMpizUXhY6u/aCQe+JkhHXm5jj4+P0s=; b=Y9C5snutQhoUAekwyTmHEXJnRaN62a/FqNj6ywvbU0VMIbnfLJln+jvcfLmhNCa14y1IGk 5o80z0o3jtyI+sn8CeNizOHGLt8Xbf2NMc0VTiI0Cojj+3j1EPQAhkbl/quarGacU1kvLX sL0mOvc6PI78W0aE1u+nr8utaJOskP4= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-674-9EsN38IlMgOm9TmfyGip1A-1; Wed, 26 Mar 2025 04:19:03 -0400 X-MC-Unique: 9EsN38IlMgOm9TmfyGip1A-1 X-Mimecast-MFC-AGG-ID: 9EsN38IlMgOm9TmfyGip1A_1742977142 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-ac28a2c7c48so37704866b.3 for ; Wed, 26 Mar 2025 01:19:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742977142; x=1743581942; 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=BJrq4mLJiJXWNMpizUXhY6u/aCQe+JkhHXm5jj4+P0s=; b=S1vrtFFnO2OI6NOc1Sa+Gm9ukaKROqA/k/C6DOsVRndlJyPuvH3PtnhT6OJWi0LMJw otX8cdI4maHG2dV+hfb7p5vPyJNCCJ9XGWpQB/IwIkFniBaFrvFt0bcIjcv3nNIyVokM 01WFtBsj4OSxNS3vNeH5pHQ1vQWYcWkPfdehS50smyMwnD0ccwON6jdgKu8WcWyaB0/8 oDwj2YwfqHlY2tCG5WNs8UFEZJhu2K6dGXVvPJt1zPI1RSCUjVtGVVQH7u6waxrgi1hI xU6xvBH29X6bthf1Lp0g8beM/wm8eCBlda7BuOgVBJE9y1vV9fbOZdqXEaG1TnqG4Smn ASDA== X-Forwarded-Encrypted: i=1; AJvYcCWqLJruilzwBV/rn/kWlkFEivHVc8MRgny2uOWhhk754YXlF9oqZxxZq27CSoYnXfQTeV3OuBBWkA==@kvack.org X-Gm-Message-State: AOJu0YzLwo/6oqhafVsrBEpTI3SbGZQO/Rt28UT9aus9s2nNgynIYhHi ejHFAt2mwVYQkiMWUl5pMO3HE8plQ3zHbO1UZM8onQ8n8Q4bEsAHqpiVWNj2HufFl4DBwD8zGJ9 uA/bzE268Lco0l5rIBJzRjfW8UZeWcWn0+AZiUbvLUjcOdZoB X-Gm-Gg: ASbGncv+b/6WcMrjFf0H2HEUWN4gnmRbIzZldX9V5cyTMwlJkyZA/rX3RwQNjy1ReI9 +F94tK0rAOTiYSTg020tqFlbg4aax1PrxhdDPTjYaWdThMvEdWttwVrqh3F8VS1Dtmw3YZJ/JMz 1l16X1vSu6pMH7TgSSXofuQMbvjYijuzkAJogHqarVFFEqBEqBbqJ9WX8GVJUC9xGAJSglPmGqm 1Iyn1xfGRHoJB+MqL3Yah5RIFFnedR2VVpvL3K1E+hVXJJxCK+4hKDdnqo3AdRmp0d2gfSsAGHP cPZdO5NnAVwUgYePKWUgfyZrtQ+2O7z+cbe8Og4t X-Received: by 2002:a17:907:96a5:b0:ac3:5c8e:d3f5 with SMTP id a640c23a62f3a-ac3f2238ac9mr1964307766b.27.1742977141996; Wed, 26 Mar 2025 01:19:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAVihNCBcqrY7fTmWzpMKedPdAfC8xKs8i1WcBmyCG1SOQFnIZkqUTCro3SjnL+rAel5iZ/A== X-Received: by 2002:a17:907:96a5:b0:ac3:5c8e:d3f5 with SMTP id a640c23a62f3a-ac3f2238ac9mr1964303566b.27.1742977141528; Wed, 26 Mar 2025 01:19:01 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac3efbe0356sm1006017366b.144.2025.03.26.01.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Mar 2025 01:19:00 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 4E36118FC9CA; Wed, 26 Mar 2025 09:18:54 +0100 (CET) From: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= Subject: [PATCH net-next v3 0/3] Fix late DMA unmap crash for page pool Date: Wed, 26 Mar 2025 09:18:37 +0100 Message-Id: <20250326-page-pool-track-dma-v3-0-8e464016e0ac@redhat.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAF2442cC/23NQQrCMBAF0KuUWRtJJmmLrryHuIjp1AZtU5IQK qV3NwQXCl3++fw3KwTylgKcqxU8JRusm3KQhwrMoKcHMdvlDMix5lJwNut8m517sei1ebJu1Ix LiVJJrRpOkJezp94uRb3CRJFNtES45WawITr/Lu+SKP1XVrtyEowzgwKpbnWrDF48dYOOR+PGA ib8QbDeRzAjQki6G3FSTS//kG3bPoiHBwcGAQAA X-Change-ID: 20250310-page-pool-track-dma-0332343a460e To: "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , Saeed Mahameed , Leon Romanovsky , Tariq Toukan , Andrew Lunn , Eric Dumazet , Paolo Abeni , Ilias Apalodimas , Simon Horman , Andrew Morton , Mina Almasry , Yonglong Liu , Yunsheng Lin , Pavel Begunkov , Matthew Wilcox Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-rdma@vger.kernel.org, linux-mm@kvack.org, =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , Qiuling Ren , Yuying Ma X-Mailer: b4 0.14.2 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 7IdtiA54rTgl9lHyodR_rGWpZJ_qF03GkPlFNFeeR5k_1742977142 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam01 X-Stat-Signature: 14sop19tythujofhaxio9w4fw7q5x6t6 X-Rspam-User: X-Rspamd-Queue-Id: 6B505100003 X-HE-Tag: 1742977145-64417 X-HE-Meta: U2FsdGVkX1+lwq3MN6cqPQT7BHJfU1BGNIk0dvUex9WczbCF7eZnr4nypQv7/gIZxzLvmj5yWg+RmU6bJPEwtJYIHnQbZV/PyysWOiYU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LgOwWKE8poZE4MP/6T0YR3eo++ngosKuv4tlqRo57xyP/OzSab/LGt4flZb11V3TgHI8G71q5j+5vELlhnJOINnduoT4cYj9AWzZ/sc7FlzQIai/s+hngC8jjlAvBPN0Pe7TravBCREpjkPFUrU6FGVN3zhrdWFMcHJbI4a4IRhs/p4ZGmjH9pIeWV0NvVQpQoOxa1jUiKITq/xDAMGFtjknoy7pt4FX70XCnSShccss2ZPPSgtIDUapoOTcDGbDLY+k0x3K8LlkVCvVUMUO28OCosJ/Fjs9KIZ5vLzF97JsYPaREZDLRBrDQbEoOzQojTizggHDcE2W/3IVAFa2FoGljzMpbUH5Wykur2YhUaff7b3GwGUeCAG/+t/R8FdeVQnxc4XK6whUcP+oxpdkFRAvQ== 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: List-Subscribe: List-Unsubscribe: This series fixes the late dma_unmap crash for page pool first reported by Yonglong Liu in [0]. It is an alternative approach to the one submitted by Yunsheng Lin, most recently in [1]. The first two commits are small refactors of the page pool code, in preparation of the main change in patch 3. See the commit message of patch 3 for the details. -Toke [0] https://lore.kernel.org/lkml/8067f204-1380-4d37-8ffd-007fc6f26738@kernel.org/T/ [1] https://lore.kernel.org/r/20250307092356.638242-1-linyunsheng@huawei.com Signed-off-by: Toke Høiland-Jørgensen --- Changes in v3: - Use a full-width bool for pp->dma_sync instead of a full unsigned long (in patch 2), and leave pp->dma_sync_cpu alone. - Link to v2: https://lore.kernel.org/r/20250325-page-pool-track-dma-v2-0-113ebc1946f3@redhat.com Changes in v2: - Always leave two bits at the top of pp_magic as zero, instead of one - Add an rcu_read_lock() around __page_pool_dma_sync_for_device() - Add a comment in poison.h with a reference to the bitmask definition - Add a longer description of the logic of the bitmask definitions to the comment in types.h, and a summary of the security implications of using the pp_magic field to the commit message of patch 3 - Collect Mina's Reviewed-by and Yonglong's Tested-by tags - Link to v1: https://lore.kernel.org/r/20250314-page-pool-track-dma-v1-0-c212e57a74c2@redhat.com --- Toke Høiland-Jørgensen (3): page_pool: Move pp_magic check into helper functions page_pool: Turn dma_sync into a full-width bool field page_pool: Track DMA-mapped pages and unmap them when destroying the pool drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 4 +- include/linux/poison.h | 4 ++ include/net/page_pool/types.h | 65 ++++++++++++++++++- mm/page_alloc.c | 9 +-- net/core/netmem_priv.h | 33 +++++++++- net/core/page_pool.c | 81 ++++++++++++++++++++---- net/core/skbuff.c | 16 +---- net/core/xdp.c | 4 +- 8 files changed, 176 insertions(+), 40 deletions(-) --- base-commit: 45e36a8e3c17c4d50ecbc863893f253fb46ac070 change-id: 20250310-page-pool-track-dma-0332343a460e