From patchwork Tue Aug 15 03:26:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13353482 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 DC2D8C04A6A for ; Tue, 15 Aug 2023 03:27:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7710290001D; Mon, 14 Aug 2023 23:27:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74BB790000B; Mon, 14 Aug 2023 23:27:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6102A90001D; Mon, 14 Aug 2023 23:27:10 -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 5608E90000B for ; Mon, 14 Aug 2023 23:27:10 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 26603B1C1C for ; Tue, 15 Aug 2023 03:27:10 +0000 (UTC) X-FDA: 81124903020.30.ADF2BA7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id 7B2D11C0006 for ; Tue, 15 Aug 2023 03:27:08 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=GU31PFG+; dmarc=none; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692070028; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LklJPoQHz5gx0kkx3SxtlRYJZMYAdukfOsnGQ5XVKy4=; b=3OBvhYE38FG0+Uf/0chcyn9MIKjXVxAruLggzymqrZK54Kj9v5fJMZ9hFyOdj+8yyE8XHt 2/JYMznTBox9Y3lvygPPPQCou+7FEXVbF3bkb0Maamro6CWYCMaH67bF7s6q+k1MB+jIb3 J6kvG2oxWMgHvpSHPOxXFsq8EWr0TeU= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=GU31PFG+; dmarc=none; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692070028; a=rsa-sha256; cv=none; b=7qxrAqPasMHzPC6E+Nwqqd16G/oyci7+0x89RqmqSY+LPhvHlQrpwrP9O0aUe65faqbo/2 d7FvDZKkYM9tQV8gwRu8E/vK45eYBjK5TVagWWhAjfdguyqn9KjOaXeXcUWu8zqeLID8MU AA3eEODXzsm3jGlK3IFTSXZbRn26U/0= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=LklJPoQHz5gx0kkx3SxtlRYJZMYAdukfOsnGQ5XVKy4=; b=GU31PFG+QORyW43Si703UzIVka mjKR/IuX+RvLygPYzwjw6rTHsyBo9ofDiCRQAP+DqpvYkUBes1SHvpYqwhbc1EQWayzS+9R+57E5d sX8G9JDumR6p4MmIoYneqnekW9XCf1UnRVlhXS4NIu5luZeraaL005PAFQh+BDLrisg6Wgb6BeBOR oQsB1Euafhr7n49QZ+PAcpaAHYUqxE0bdhrJ6xrZxezyUmxbTKaErzLHGhuSWf6FsI3CTeLKAQHNz VivihZYRv6iRluHL6MI0fPb3p7DMD2x+GnoI18HsrNBbK+CzxYG/tXYkPRzpMQR5tPMNPxGWoK8EZ +mMRKj9g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qVkhm-005qaR-5N; Tue, 15 Aug 2023 03:26:50 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Jens Axboe , io-uring@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/9] io_uring: Stop calling free_compound_page() Date: Tue, 15 Aug 2023 04:26:37 +0100 Message-Id: <20230815032645.1393700-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230815032645.1393700-1-willy@infradead.org> References: <20230815032645.1393700-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 4p754d4tspkzwaxdm6hubnko5cd3kxrk X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7B2D11C0006 X-HE-Tag: 1692070028-181820 X-HE-Meta: U2FsdGVkX18xXYG96iSkil6Rw72U8WbxiMYDZ3B/mUV/ecAiGjgjE62DTMF1Z3yhKuqahiHPHUbvKeaRRccRVKQDYufME0oWcwTF1A6j39LHsBdgE7OsnW+8ng7E8M3PUNUktEeK4T7EqF9KwNCgCCtt/JtmBzuuN0lfiK2Hhvkmr9+o0sN0w7toquB0fDkR7ikvgs47Sg0niOjf8AGahczbJaNKvY/TcbYYTL0+7P9ynMyWNxQX7PNxje3pZiaWuD1fw9pYJsEV4keo8GDx52HA/HHXSAl3/GlE0y4wgUcIvTqkuHQ4MlFrDwH6Ve1G7iT5iYAQoWC4VHGzuen+GXT+2aTopwmYKJE14T6wC/V2b5jODBuap94oy9paIvAm5IZDVOB+eb6lo81vLHIidKUD85ZeLWkytUj1TsSGy9wuUWiAwhsTbQY+2XL0Q/xEOxd8UOTg+zhWbuBnYqfadTcrhtxKnHmTQ116WkHvSCzsf9zWNz4l3+aA5M6pMDIs5qcfladUg5oMrI2qFnprzMOrmrir11R+FjtTvjpdvjRu0oczbQic2sBaKj09l6P1ZDiinS9J/xHOCObdTmJD+2XN2AvvBdEBPpvICsj3TbSsHCr0WXNbrXW2P2zQIBJAUyz7xIkNKNmbAUYD2ejghRblVfkG2o/uuPg+cLMrCQbKh5CBgPJ89+3a1FU5EFpJEB20le2GywoaYF7u3IY1H8UYdO0vfOnBD7CFQDQezCpvMN0JA0/c2bmR/K0u8NpqrOKKwdtNahvMnJte25sTts0LrQtrBBujGYwH8uaQj2cqKZBW5jrcgMSa2ELzm0e2qtxLwQX3cjvYinJixir/MpXdrJp/qYVj6fFEQnzXhZ5yjwE4fpoJBTeBQhY1uBqvAn7boPohJyOrC3KzE7eD4/YHGD7BJgINYpV5I1o0hfCGI3tDWbUoQ0q69KoHUSZ8oTq+tBkPVsMWrhyah0H ywwUdUIr IuKuWJZu/1DTHxEjwGvP0to/dCRW+qOx0wpS21LSQDzpBwmrTp0wtmfju4sifBUD8g/fHUmyvzmJV4el6/6q8B1fqi1s3KweP0/jC356BeUl2cXn+P9345z+loQj8ZF1myw2vhTh1TL2718GyKwlmJMSxV79mF4BSI/c2EPeUaMmTYMbGSpFbXwvmGuFWxvqP4Gx17uyhmU18USpGxYuKMwjGlV2TucA5fm6x 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: folio_put() is the standard way to write this, and it's not appreciably slower. This is an enabling patch for removing free_compound_page() entirely. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand Reviewed-by: Jens Axboe --- io_uring/io_uring.c | 6 +----- io_uring/kbuf.c | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index dcf5fc7d2820..a5b9b5de7aff 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2664,14 +2664,10 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, static void io_mem_free(void *ptr) { - struct page *page; - if (!ptr) return; - page = virt_to_head_page(ptr); - if (put_page_testzero(page)) - free_compound_page(page); + folio_put(virt_to_folio(ptr)); } static void io_pages_free(struct page ***pages, int npages) diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index 2f0181521c98..556f4df25b0f 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -218,11 +218,7 @@ static int __io_remove_buffers(struct io_ring_ctx *ctx, if (bl->is_mapped) { i = bl->buf_ring->tail - bl->head; if (bl->is_mmap) { - struct page *page; - - page = virt_to_head_page(bl->buf_ring); - if (put_page_testzero(page)) - free_compound_page(page); + folio_put(virt_to_folio(bl->buf_ring)); bl->buf_ring = NULL; bl->is_mmap = 0; } else if (bl->buf_nr_pages) {