From patchwork Tue May 23 14:52:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Dangaard Brouer X-Patchwork-Id: 13252482 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 7B998C77B75 for ; Tue, 23 May 2023 14:52:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAEC46B0074; Tue, 23 May 2023 10:52:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5EEA6B0075; Tue, 23 May 2023 10:52:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 926F9900002; Tue, 23 May 2023 10:52:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7EA796B0074 for ; Tue, 23 May 2023 10:52:57 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4F9FC160568 for ; Tue, 23 May 2023 14:52:57 +0000 (UTC) X-FDA: 80821811994.14.5EA5E38 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id E1790A0014 for ; Tue, 23 May 2023 14:52:54 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g75zfvYD; spf=pass (imf25.hostedemail.com: domain of brouer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=brouer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684853575; 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=KHDYxPG+OnNKEEbmravfdg4Ujk0LU1sywu09RiZg4i4=; b=1V+1P/lC1R0AGaeL2ChiS24bDJ8aVJgotm2/af/UOEFqc8dmY/3jPPTGqLcSJdnlQ2h9vW BMCe0Fs12kRByhVPvfHwUwgfcENDDtjvAVsxsyP/tcdzMpMuQSwOsxQNRkBPMajOVloX29 MfMxez1oT0Mq99X88NR035TUXXkTncc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684853575; a=rsa-sha256; cv=none; b=zJICm6/ZYUMpgoXojWgSmnel0Ln55zz7VypZx8bL64aIi+cdbG6WIc05j2r7MR6Gsi2KGU uWPXPLXmkG+wx2keO1ioPq2eNXXU0MxEPgWar7DJM3zTMMIiYBp8Q5tPiZa51Frn/16GF1 aPsJO7lOaWKMfFoziqTyBfqOnLStKOM= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g75zfvYD; spf=pass (imf25.hostedemail.com: domain of brouer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=brouer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684853574; 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=KHDYxPG+OnNKEEbmravfdg4Ujk0LU1sywu09RiZg4i4=; b=g75zfvYDiy7elwZb0MIiAQCirHluf7jqT/F6x1N474B+H7PjZTKoQAbESoOHLcXDr+ubnn KI+WBIS4UW0Tn3S2YQEdbxo5riYpHSzx8mzEYXBnonIrV+0xdsXIw0OaInrMKJqsKMRYof 5V/Oc7U4s8xG2hhmF6IqbY86LAT2dQE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-450-gQyoRNafPJqNEodLpHa1nw-1; Tue, 23 May 2023 10:52:50 -0400 X-MC-Unique: gQyoRNafPJqNEodLpHa1nw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 063B929AA3B0; Tue, 23 May 2023 14:52:50 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 620A11121314; Tue, 23 May 2023 14:52:49 +0000 (UTC) Received: from [10.1.1.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 3A424307372E8; Tue, 23 May 2023 16:52:48 +0200 (CEST) Subject: [PATCH RFC net-next/mm V4 0/2] page_pool: new approach for leak detection and shutdown phase From: Jesper Dangaard Brouer To: Ilias Apalodimas , netdev@vger.kernel.org, Eric Dumazet , linux-mm@kvack.org, Mel Gorman Cc: Jesper Dangaard Brouer , lorenzo@kernel.org, =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , linyunsheng@huawei.com, bpf@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Paolo Abeni , Andrew Morton , willy@infradead.org Date: Tue, 23 May 2023 16:52:48 +0200 Message-ID: <168485351546.2849279.13771638045665633339.stgit@firesoul> User-Agent: StGit/1.4 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: E1790A0014 X-Rspam-User: X-Stat-Signature: ownugf5zp8k13yy7msfu7tqir1q93esu X-Rspamd-Server: rspam03 X-HE-Tag: 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t4EPFEZWCuXXGbbPTq4DkB6Rr3KluJpLu3p0UG3BMrxfgyvf5FsXPJBce1h+3dx32O7XhfZCzDB3Cycmw7zRBhFbD9nHDK4W6Nv4fPvLr/qyBY5bVGquSb6VkHik6OTUR8AWllRiCpy3l4jn62YaqFpaopVOSvTCVeEE/yjnmRTFa3yO8c2QZ0phEDhMoKagCCr7s96hhGISKtD5pMzGSyxbjMFJVBJ6WUb0Sa15DrvZUdFO7hubT5VxrfchexdRbtIY8= 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: Patchset change summary: - Remove PP workqueue and inflight warnings, instead rely on inflight pages to trigger cleanup - Moves leak detection to the MM-layer page allocator when combined with CONFIG_DEBUG_VM. The page_pool (PP) workqueue calling page_pool_release_retry generate too many false-positive reports. Further more, these reports of page_pool shutdown still having inflight packets are not very helpful to track down the root-cause. In the past these reports have helped us catch driver bugs, that leaked pages by invoking put_page directly, often in code paths handling error cases. PP pages had a shorter lifespan (within driver and XDP code paths). Since PP pages got a recycle return path for SKBs, the lifespan for a PP page can be much longer. Thus, it is time to revisit periodic release retry mechanism. The default 60 sec lifespan assumption is obviously wrong/obsolete, as things like TCP sockets can keep SKBs around for much longer (e.g. retransmits, timeouts, NAPI defer schemes etc). The inflight reports, means one of two things: (1) API user is still holding on, or (2) page got leaked and will never be returned to PP. The PP need to accept it have no control over (1) how long outstanding PP pages are kept by the API users. What we really want to is to catch are(2) pages that "leak". Meaning they didn't get proper returned via PP APIs. Leaked PP pages result in these issues: (A) We can never release page_pool memory structs, which (B) holds on to a refcnt on struct device for DMA mapping, and (C) leaking DMA-mappings that (D) means a hardware device can potentially write into a page returned to the page allocator. V4: Use RCU sync method to resolve races V3: Fix races found Toke V2: Fix race found by Yunsheng Lin --- Jesper Dangaard Brouer (2): mm/page_pool: catch page_pool memory leaks page_pool: Remove workqueue in new shutdown scheme include/net/page_pool.h | 10 +-- mm/page_alloc.c | 7 ++ net/core/page_pool.c | 138 ++++++++++++++++++++++++++++------------ 3 files changed, 111 insertions(+), 44 deletions(-) --