From patchwork Wed Aug 16 15:11:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13355393 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 7FEA2C001E0 for ; Wed, 16 Aug 2023 15:13:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1317C28002A; Wed, 16 Aug 2023 11:13:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DF58280021; Wed, 16 Aug 2023 11:13:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE93228002A; Wed, 16 Aug 2023 11:13:57 -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 E0F2F280021 for ; Wed, 16 Aug 2023 11:13:57 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 735BD80E90 for ; Wed, 16 Aug 2023 15:13:57 +0000 (UTC) X-FDA: 81130312914.12.07D36F4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id A6C8080023 for ; Wed, 16 Aug 2023 15:12:33 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=V4d1z6UW; dmarc=none; spf=none (imf30.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=1692198753; 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=jXAd6te3eevEbVqabkMpBNzRJH0aU7U0+nA6iByh2bk=; b=vvH/TxxC6rJZVf7oCjY9Mw11ctek2uKVuHaOL7JmdIVOcYah2rdRwWmXQn+DxioiJfjpTW O4jyMuZlhtJdOrELnWDeQ0/JWPnTSVdLRC1QkHotP6ulfh2HRJGX0xJYUzouCgq5DBCLu1 i3lhLpy+hAdbFpmcLAehUg1gmfkVKIQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=V4d1z6UW; dmarc=none; spf=none (imf30.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=1692198753; a=rsa-sha256; cv=none; b=3RutR6mV+wikbF+GY4O0rug8ewRZc/fjHkdHmXKIQfEbmNtVJH/N9tArl22n02SmlHSXf2 c8NCoMalDv0vM3cvrJjgVd1uvEmFcv6Kho+zc47+MYIYalF1A5VWGnNgci6QZbx63FwJNL Esr+lLOyspdykjaE4TPZf7nJ7Gxrf6I= 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=jXAd6te3eevEbVqabkMpBNzRJH0aU7U0+nA6iByh2bk=; b=V4d1z6UWihqSb/dNTj9KkjPJjC or7aj4YOKjDW9jwii8ErZHlhHochwR/HSrYKVXI3b1zrI8iUnkC0u+Yr9/rMo1Qi7PhoSTyiOAnt4 yQgVLhmctuEGzQOEWtSrAtXo4ShPRDQL8SgC8P1r/xp1L2ePmGScEChQM2z2aQdairZLStValuMTd Vq0e9Is6O6Duw44HTFIkGHuGTk4im0XJqTI4P8OzNbR6JXuJ/tBfZGw4CUDf4b+XiuaVyyF3LArSy znBt2uuXD0y8iQotfzRJPM8f37dXfsx6V34jcQuQ85JZKPCyVEa2vSiWOwzrbXxcXY3ZS9p+vS7Fy XSd7dsjw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qWIBt-00FL8P-Uf; Wed, 16 Aug 2023 15:12:09 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Jens Axboe , io-uring@vger.kernel.org, linux-mm@kvack.org, David Hildenbrand Subject: [PATCH v2 01/13] io_uring: Stop calling free_compound_page() Date: Wed, 16 Aug 2023 16:11:49 +0100 Message-Id: <20230816151201.3655946-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230816151201.3655946-1-willy@infradead.org> References: <20230816151201.3655946-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: A6C8080023 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 53bh8rus8smguciruyx5xef7a366ucjf X-HE-Tag: 1692198753-856665 X-HE-Meta: U2FsdGVkX1+rqnXZQ7TSQXwpRNYyN96fTWv72JhrBmRefZzF5xynr58GFVG534fCHddG3ajYpKfNwaqmBFlo9CIcvapF9nSGrvEcOg8EOhw5uDJddE7cejpuZayyn/chwXRbE9rcNC14slxfg/DYr/KZfGnxCqqeFDGiq2sorSQ41DB0OxRt6+NSjdkccNhTQg1ZvNGYhNirfchABx2FowbVy8L/7iOsjgSe+ueYZHamQTjPKBQFleeq6lWK0H/NFBhhCdLfPKnh7o7ZZWkmfWTe2w1+Yx07/4ndzfTW+1bcP4VenYTwLfMVNqxAgW1w6dbStCkURPnjw9QiRasw74tkwtLuqPRNsZfl66NX98SPfmdyxugGxSyXeIjjKVlrscxgaNWdFzeKQ+zNc1bc0IIayhmP+wDjxGXyag4EUB9VxraNUu2Wm/3avUz58I3aZuj9m6nxAAhUCgHQxfL6oER7rIxfYSXSxElM8WVhuiiPsz/Hh/XkDosL4W2hgHtR0/VVRbXM45rY47XBljAK42swfEvhKLd2WvtG/1fzEkMC8Qr/vmBN3KREBAcbADck3kwT6n/sKWek2J66holjPrZEL3ljdbKZ+2MNlgxrj0p2SkxH+PynyC9GSlfh1QPBCIL2+3LoQw4kqaPmIKI1c8OawfIKe2bmuWe2nA0X1T5tO7U0fOtQ7dujCPXFegEbJVTzyayuXDoF3vd9vZW2pcGmLkSyl+vLuQKM6cdO4WkCO07b/G34SZeM9h7ObOuuGC8a5Z50d0Zw1ZFMu/HL6skDU4C1d91CYsTOmn4E+DX29BSI12txQPL3nQ+SQGEB5tinV9PsXgkLaV1mA7h9W0veRJrWS29Hb/mkWAThWRk4iZc7AUh84TgCV+O0rxlDUCYzZ8QQACAGAa9gvh8oYtcSOtwdBFUiUCl9nTH2/NxjHrxc4AV9tuAbd7ZyqP3mU3xH4cL4NqlieMlNrvh yuFaOaWb TO6lHDZlYleVw0E2YI4JK7lj65q4AtItHOG3Ii8+DxWcmBogBLcQwCbnvCW4H48uMZWaugMGQB/T6JnFBrGW1EUS9p/l4xcN6Jsan3U30y9LUwepSURmwRo8uAYuFIVde7NIf/W2gVrv/iT6nYzITWKsNwHaniNGP0GU0V9IEvT/eOexy7uC1OnN8nkThY7YADktbaK58AD6K3Xligt2yafwZAbDZ7NklMR478svfNiUMFuHYNM7N7mptvA== 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) {