From patchwork Fri Apr 28 16:16:14 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: 13226624 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 D8C95C77B60 for ; Fri, 28 Apr 2023 16:16:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5736D6B0080; Fri, 28 Apr 2023 12:16:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FBFC6B0081; Fri, 28 Apr 2023 12:16:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39CB46B0082; Fri, 28 Apr 2023 12:16:24 -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 279CB6B0080 for ; Fri, 28 Apr 2023 12:16:24 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 036804016B for ; Fri, 28 Apr 2023 16:16:23 +0000 (UTC) X-FDA: 80731302288.30.7098B28 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 210BD40022 for ; Fri, 28 Apr 2023 16:16:21 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dhxBokgp; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of brouer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=brouer@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682698582; 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=TvewqYuSzWNN7mxtbeM4khKlAp2Yo8QXThhKD8ctzeY=; b=vQVOpH0c99e4tO8gT3f4UAo94FWoyMMR87nFGz+8PzDtr1YC/5Pe/aLM42KQp4jRvFfjwA Ly3Pvb7i/RDC1lSkyGafUmB7q+OK1mXedeEiioEVp/dQAvuG9Ph6G5SAV6R4a2+OTLm9QS aelZdcS2vNEl8ZFb53VX/YBUKnKqGmY= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dhxBokgp; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of brouer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=brouer@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682698582; a=rsa-sha256; cv=none; b=ejd//vcUUpw55sS8E/wY+ZLYFILy9wbuh0yMr6Hj3fpRolWMh4bcINihM3ZwKIrKdyJnw+ 1nFEMc0Uu7tDTDKZ1Ry7nWWtKV6CQl3tEw7fNN4nIdeUF+rNAjyXxIlJeXxm4irLXi8r/Z PJ/LP1pYrwFn+1G52tpvUUAWTdI4vDI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682698581; 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=TvewqYuSzWNN7mxtbeM4khKlAp2Yo8QXThhKD8ctzeY=; b=dhxBokgp0sQMHWTZRvF2SXFNAUd/vjw14hDvKQKOuH1LRW+PFykrCkFH64XwrYXcn4Odr5 5tHJDcZ+kPzfEmblDf8JkKexK0KXQm5ZeqkIyGUguDrRy2I60Y2QMH1LYrKDqStgQ96gIu y646HLdmxYzY1R2JMNo9cvDg/bJOd5k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-616-d-dIVHqjMJOFk9aCOr-jjg-1; Fri, 28 Apr 2023 12:16:16 -0400 X-MC-Unique: d-dIVHqjMJOFk9aCOr-jjg-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 9073D185A790; Fri, 28 Apr 2023 16:16:15 +0000 (UTC) Received: from firesoul.localdomain (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B884492C13; Fri, 28 Apr 2023 16:16:15 +0000 (UTC) Received: from [10.1.1.1] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 43564307372E8; Fri, 28 Apr 2023 18:16:14 +0200 (CEST) Subject: [PATCH RFC net-next/mm V3 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: Fri, 28 Apr 2023 18:16:14 +0200 Message-ID: <168269854650.2191653.8465259808498269815.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: rspam02 X-Rspamd-Queue-Id: 210BD40022 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QPQZOv07S33MduiT5HNPE2vHjKB6J2jzF880nHDcNk2bDbvPaSHkGICmCzOEF0RzWfF0phIsYIMCmqkbsZzLtFok0ZBs0m8sJE9Eu/wiO95S433mRnTTqNS19nzW5WM8RtowqXnQ9+t66+jO/b3x2jy3L62y3zkHC18VnXiGxPeFKprgvju9z6BjixvCJu2OKnanUGC/IwVve/C2MNWHuCi/jHAUvQgCl10qL9KLJvdPHlXFOeG3TMebD5d4vFSfkye+PrULkCoJWkHIUXgZlWJFyGXg+lBF0OR+s0tDq6eyogHr3tqI3GbQQFiIhxc/LjMhY= 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. V3: Fix races found Toke V2: Fix race found by Yunsheng Lin --- Jesper Dangaard Brouer (2): page_pool: Remove workqueue in new shutdown scheme mm/page_pool: catch page_pool memory leaks include/net/page_pool.h | 9 ++- mm/page_alloc.c | 7 ++ net/core/page_pool.c | 138 ++++++++++++++++++++++++++++------------ 3 files changed, 110 insertions(+), 44 deletions(-) -- Jesper