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: 13223541 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C4E5C77B61 for ; Tue, 25 Apr 2023 17:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234055AbjDYRQe (ORCPT ); Tue, 25 Apr 2023 13:16:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234621AbjDYRQe (ORCPT ); Tue, 25 Apr 2023 13:16:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB1A010EA for ; Tue, 25 Apr 2023 10:15:42 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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(-) --