From patchwork Tue Apr 25 17:15:33 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: 13223545 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 8AF0AC6FD18 for ; Tue, 25 Apr 2023 17:15:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5FF36B008C; Tue, 25 Apr 2023 13:15:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D0FD56B0092; Tue, 25 Apr 2023 13:15:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFE9D6B0093; Tue, 25 Apr 2023 13:15:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B04926B008C for ; Tue, 25 Apr 2023 13:15:44 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 73BA8402F4 for ; Tue, 25 Apr 2023 17:15:44 +0000 (UTC) X-FDA: 80720565408.14.CEA821A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 782E7100015 for ; Tue, 25 Apr 2023 17:15:42 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KY7DJs0z; spf=pass (imf14.hostedemail.com: domain of brouer@redhat.com designates 170.10.129.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=1682442942; 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=oP7XGV5VExr1rl4THY8dltENlH5jFEKZbogxAYTLfQ4=; b=BNgsktKJFrZ263cZsedMnRy3xDphMmDeCRzqyoXVlLCscmqZnGk+vZdFO951af2m4miOZW 1AwlgC7u/nVrujWd0KV9vjyJU4d8FAU+7Id/1SYwUKg9ASdWj7uIQ2tecWrIcPoqVh8k1s VXhgATz58i6MvlNyrry0vCtagdl/zy8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KY7DJs0z; spf=pass (imf14.hostedemail.com: domain of brouer@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=brouer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682442942; a=rsa-sha256; cv=none; b=FTYUuBKZSlmKeN68i1oLhbx+DZ9hQwt/m6X+70dSBcF4bfxbn219+ahulv2hcfKYuOS6Cj 9cTo/7rGGXMII9UCIm2k69vdHEuJItxtvW3kHxWHNf6mgkU1NfjR1IcdbIhNNSRsNG6OAs ew4thUsyhi6MpEBYtPaL2ZUzTyQ5tmY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682442941; 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=oP7XGV5VExr1rl4THY8dltENlH5jFEKZbogxAYTLfQ4=; b=KY7DJs0znzs0xfsD0rECDhcO8AUUdSybFkk33xaClmedTsIo+Km/9hoIrgrDZBtsTKoG39 iBtCOFb+5ZYfUd660apVrJRysKVj/CkOOI+XSvh0rp3e/u2/W/nrvHiEt6nCQ4ch3Zo8GV 4MircSUClcUi5/eXlmA/zNLkBx/XCgs= 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-663-C8LH0YQ-PIqu0TSpK_f8EA-1; Tue, 25 Apr 2023 13:15:38 -0400 X-MC-Unique: C8LH0YQ-PIqu0TSpK_f8EA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6C59E1C0515E; Tue, 25 Apr 2023 17:15:35 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id C95F8492C14; Tue, 25 Apr 2023 17:15:34 +0000 (UTC) Received: from [10.1.1.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id B4F61307372E8; Tue, 25 Apr 2023 19:15:33 +0200 (CEST) Subject: [PATCH RFC net-next/mm V1 0/3] 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, 25 Apr 2023 19:15:33 +0200 Message-ID: <168244288038.1741095.1092368365531131826.stgit@firesoul> User-Agent: StGit/1.4 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 782E7100015 X-Stat-Signature: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+LHAw2q4F8ExfuaV0PWf25SFQ1bVKWFZCrAPbLBsht/GplFFyoRmiEhU+BSIaEuw3wNUPXNFrj85w+uDY04XqTDLplnF5EnVNIH+Kkdon8E1K/E4hkmP2gwat9fJIZGZYqHY9a4/2fUOuH0Nu7qSNtBVUhUqSPTeyEryWBcD1Nl1ffaDoL7FxV6lWDiFeP5LLx7JqeeL99XsreKUfBIeUtfBrFRNTIPxr8jiI/p2bxgvU9LvMdbfrfoA4= 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. --- Jesper Dangaard Brouer (3): page_pool: Remove workqueue in new shutdown scheme page_pool: Use static_key for shutdown phase mm/page_pool: catch page_pool memory leaks include/net/page_pool.h | 9 +++--- mm/page_alloc.c | 7 +++++ net/core/page_pool.c | 61 +++++++++++++++++++++-------------------- 3 files changed, 42 insertions(+), 35 deletions(-) --