From patchwork Fri Nov 6 12:30:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11887067 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE4626A2 for ; Fri, 6 Nov 2020 12:30:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 96CC220825 for ; Fri, 6 Nov 2020 12:30:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="HxehHPhH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96CC220825 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 14B396B0068; Fri, 6 Nov 2020 07:30:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0A9A86B006C; Fri, 6 Nov 2020 07:30:48 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA2D86B006E; Fri, 6 Nov 2020 07:30:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id AD0716B0068 for ; Fri, 6 Nov 2020 07:30:47 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4A9F73628 for ; Fri, 6 Nov 2020 12:30:47 +0000 (UTC) X-FDA: 77453927334.30.store82_300311d272d2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 218B1180B3AA7 for ; Fri, 6 Nov 2020 12:30:47 +0000 (UTC) X-Spam-Summary: 1,0,0,797d9153dbc3dc71,d41d8cd98f00b204,willy@infradead.org,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1542:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:3138:3139:3140:3141:3142:3353:3740:3865:3867:3871:4321:4385:4605:5007:6261:6653:7875:8603:10004:11026:11473:11658:11914:12048:12296:12297:12555:12895:12986:13894:14096:14181:14394:14721:21080:21451:21627:21987:21990:30054,0,RBL:90.155.50.34:@infradead.org:.lbl8.mailshell.net-62.8.15.100 64.201.201.201;04yg1fk3cphjisogo8w1ospjtp4pmoph6eadjafandr8fpak8irqdr8qu73xhse.m3ki8txkm35r7n6rhzf8wn4sgi4tymojemmt5z4uiihah1mu8sefzs3nna6k3i5.q-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:71,LUA_SUMMARY:none X-HE-Tag: store82_300311d272d2 X-Filterd-Recvd-Size: 3898 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Nov 2020 12:30:46 +0000 (UTC) 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=gsFgv0Jl3de0Za5CmEKC4EBbImhC0dOH10o2Itd6Aww=; b=HxehHPhHIHgDisPrPQVHGR9MDh QfBCP5dd9cFAPqMH7DW0DISdB1wbDhIPt9vKrjfM0Y2ncdPxkMNEIR95+DVEz1eXMrUdBkojrvqK6 nL5JIGu4OJDQQ7gV5fBbK2kOLZZu3DmuFhyT6TvvCQ/3a7pA700k11XLFVPnIteswTXpfQBaPZl35 vCyxa4JjrD/MLlENUCe0XTrL5e8sq+klrZsC7KsXrAZJRANhexckf/RnxioTr+uXIRaob6UOUuZMU nnfGIIFXuUq910SEcQlyyxmjl+xf4TiDTkSpnwazY4Pur67y/86cvo1DdnEYhTUHcmR4mTeStbQbS 7yzwOcew==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb0t8-0007Qe-0t; Fri, 06 Nov 2020 12:30:42 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, hch@lst.de, kent.overstreet@gmail.com Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 1/4] pagevec: Allow pagevecs to be different sizes Date: Fri, 6 Nov 2020 12:30:37 +0000 Message-Id: <20201106123040.28451-1-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201106080815.GC31585@lst.de> References: <20201106080815.GC31585@lst.de> MIME-Version: 1.0 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: Declaring a pagevec continues to create a pagevec which is the same size, but functions which manipulate pagevecs no longer rely on this. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagevec.h | 20 ++++++++++++++++---- mm/swap.c | 8 ++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 875a3f0d9dd2..ee5d3c4da8da 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -18,9 +18,15 @@ struct page; struct address_space; struct pagevec { - unsigned char nr; - bool percpu_pvec_drained; - struct page *pages[PAGEVEC_SIZE]; + union { + struct { + unsigned char sz; + unsigned char nr; + bool percpu_pvec_drained; + struct page *pages[PAGEVEC_SIZE]; + }; + void *__p[PAGEVEC_SIZE + 1]; + }; }; void __pagevec_release(struct pagevec *pvec); @@ -41,6 +47,7 @@ static inline unsigned pagevec_lookup_tag(struct pagevec *pvec, static inline void pagevec_init(struct pagevec *pvec) { + pvec->sz = PAGEVEC_SIZE; pvec->nr = 0; pvec->percpu_pvec_drained = false; } @@ -50,6 +57,11 @@ static inline void pagevec_reinit(struct pagevec *pvec) pvec->nr = 0; } +static inline unsigned pagevec_size(struct pagevec *pvec) +{ + return pvec->sz; +} + static inline unsigned pagevec_count(struct pagevec *pvec) { return pvec->nr; @@ -57,7 +69,7 @@ static inline unsigned pagevec_count(struct pagevec *pvec) static inline unsigned pagevec_space(struct pagevec *pvec) { - return PAGEVEC_SIZE - pvec->nr; + return pvec->sz - pvec->nr; } /* diff --git a/mm/swap.c b/mm/swap.c index 2ee3522a7170..d093fb30f038 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -52,6 +52,7 @@ struct lru_rotate { }; static DEFINE_PER_CPU(struct lru_rotate, lru_rotate) = { .lock = INIT_LOCAL_LOCK(lock), + .pvec.sz = PAGEVEC_SIZE, }; /* @@ -70,6 +71,13 @@ struct lru_pvecs { }; static DEFINE_PER_CPU(struct lru_pvecs, lru_pvecs) = { .lock = INIT_LOCAL_LOCK(lock), + .lru_add.sz = PAGEVEC_SIZE, + .lru_deactivate_file.sz = PAGEVEC_SIZE, + .lru_deactivate.sz = PAGEVEC_SIZE, + .lru_lazyfree.sz = PAGEVEC_SIZE, +#ifdef CONFIG_SMP + .activate_page.sz = PAGEVEC_SIZE, +#endif }; /* From patchwork Fri Nov 6 12:30:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11887055 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4AE86A2 for ; Fri, 6 Nov 2020 12:30:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4C3C12087E for ; Fri, 6 Nov 2020 12:30:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Rd5xXhJr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C3C12087E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 36A5D6B005C; Fri, 6 Nov 2020 07:30:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 319E76B005D; Fri, 6 Nov 2020 07:30:45 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 231676B0068; Fri, 6 Nov 2020 07:30:45 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id E83876B005C for ; Fri, 6 Nov 2020 07:30:44 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 920B4180AD815 for ; Fri, 6 Nov 2020 12:30:44 +0000 (UTC) X-FDA: 77453927208.29.tail95_101587e272d2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 73A4C180868EE for ; Fri, 6 Nov 2020 12:30:44 +0000 (UTC) X-Spam-Summary: 1,0,0,08b36996b336a699,d41d8cd98f00b204,willy@infradead.org,,RULES_HIT:41:69:355:379:541:800:960:966:967:968:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1542:1711:1730:1747:1777:1792:2196:2199:2393:2525:2559:2563:2682:2685:2859:2897:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3865:3866:3867:3870:3871:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4385:4605:5007:6119:6261:6653:7903:8603:9025:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:12986:13845:13894:14096:14181:14394:14721:21080:21347:21451:21627:21740:21749:21811:21987:30029:30054,0,RBL:90.155.50.34:@infradead.org:.lbl8.mailshell.net-64.201.201.201 62.8.15.100;04y8q4nf5ethnuogdwze6c7o6kephop67gfarihy76yik8djj6bdkht1e78k7q6.k6fkceqh91xpax6hkp714jhmru99wo5zppd9k5k7zrb5938p1wetdq5iad6nkfa.q-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral, Custom_r X-HE-Tag: tail95_101587e272d2 X-Filterd-Recvd-Size: 4236 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Nov 2020 12:30:43 +0000 (UTC) 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=6tUINAMJjUdq6LPonn3cLBWKxJPktFDlylPf+keuUGY=; b=Rd5xXhJrZyFlBMKU+t+tU6YQBt DpB39P7+K4us9Xtob24m4tOMLG61acjJu8Hv08zmzE+LK1nRqxQ6q4HkjiPMg/SkNfhsWUQfAClH1 /aueSdDKNGP2/6iTeZ9VWx+0NzonkHyVeHbejiDmj1StBj1PjMCFqqhvlvwPwt8SWK7Fvt/ywbNV8 DVB9AQQ+rJepsrXGjz8SWa+PX9SfvZyEjqMDxsNAC2GijrUORkbDYCQ7iWaQvEGa3jkUICESEcVcI s8n/ojnT9sxCZX3clNWHCFZTjMakXfJvZ3jmVxiOi/AKhDSSWYfEc27s9JKAgu1kbMdMST5gqGk4M rM5DoKuA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb0t8-0007Qh-8Q; Fri, 06 Nov 2020 12:30:42 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, hch@lst.de, kent.overstreet@gmail.com Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 2/4] pagevec: Increase the size of LRU pagevecs Date: Fri, 6 Nov 2020 12:30:38 +0000 Message-Id: <20201106123040.28451-2-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201106123040.28451-1-willy@infradead.org> References: <20201106080815.GC31585@lst.de> <20201106123040.28451-1-willy@infradead.org> MIME-Version: 1.0 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: Tim Chen reports that increasing the size of LRU pagevecs is advantageous with a workload he has: https://lore.kernel.org/linux-mm/d1cc9f12a8ad6c2a52cb600d93b06b064f2bbc57.1593205965.git.tim.c.chen@linux.intel.com/ Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagevec.h | 5 +++++ mm/swap.c | 27 +++++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index ee5d3c4da8da..4dc45392d776 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -29,6 +29,11 @@ struct pagevec { }; }; +#define declare_pagevec(name, size) union { \ + struct pagevec name; \ + void *__p ##name [size + 1]; \ +} + void __pagevec_release(struct pagevec *pvec); void __pagevec_lru_add(struct pagevec *pvec); void pagevec_remove_exceptionals(struct pagevec *pvec); diff --git a/mm/swap.c b/mm/swap.c index d093fb30f038..1e6f50b312ea 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -45,14 +45,17 @@ /* How many pages do we try to swap or page in/out together? */ int page_cluster; +#define LRU_PAGEVEC_SIZE 63 +#define lru_pagevec(name) declare_pagevec(name, LRU_PAGEVEC_SIZE) + /* Protecting only lru_rotate.pvec which requires disabling interrupts */ struct lru_rotate { local_lock_t lock; - struct pagevec pvec; + lru_pagevec(pvec); }; static DEFINE_PER_CPU(struct lru_rotate, lru_rotate) = { .lock = INIT_LOCAL_LOCK(lock), - .pvec.sz = PAGEVEC_SIZE, + .pvec.sz = LRU_PAGEVEC_SIZE, }; /* @@ -61,22 +64,22 @@ static DEFINE_PER_CPU(struct lru_rotate, lru_rotate) = { */ struct lru_pvecs { local_lock_t lock; - struct pagevec lru_add; - struct pagevec lru_deactivate_file; - struct pagevec lru_deactivate; - struct pagevec lru_lazyfree; + lru_pagevec(lru_add); + lru_pagevec(lru_deactivate_file); + lru_pagevec(lru_deactivate); + lru_pagevec(lru_lazyfree); #ifdef CONFIG_SMP - struct pagevec activate_page; + lru_pagevec(activate_page); #endif }; static DEFINE_PER_CPU(struct lru_pvecs, lru_pvecs) = { .lock = INIT_LOCAL_LOCK(lock), - .lru_add.sz = PAGEVEC_SIZE, - .lru_deactivate_file.sz = PAGEVEC_SIZE, - .lru_deactivate.sz = PAGEVEC_SIZE, - .lru_lazyfree.sz = PAGEVEC_SIZE, + .lru_add.sz = LRU_PAGEVEC_SIZE, + .lru_deactivate_file.sz = LRU_PAGEVEC_SIZE, + .lru_deactivate.sz = LRU_PAGEVEC_SIZE, + .lru_lazyfree.sz = LRU_PAGEVEC_SIZE, #ifdef CONFIG_SMP - .activate_page.sz = PAGEVEC_SIZE, + .activate_page.sz = LRU_PAGEVEC_SIZE, #endif }; From patchwork Fri Nov 6 12:30:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11887069 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 083296A2 for ; Fri, 6 Nov 2020 12:30:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A02B220825 for ; Fri, 6 Nov 2020 12:30:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="wDr7t34w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A02B220825 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 936D76B006E; Fri, 6 Nov 2020 07:30:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8C5246B0070; Fri, 6 Nov 2020 07:30:48 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CAC86B0071; Fri, 6 Nov 2020 07:30:48 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 331E06B006E for ; Fri, 6 Nov 2020 07:30:48 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id BAEF71EE6 for ; Fri, 6 Nov 2020 12:30:47 +0000 (UTC) X-FDA: 77453927334.09.name81_2a0a0ec272d2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 9EDF1180AD815 for ; Fri, 6 Nov 2020 12:30:47 +0000 (UTC) X-Spam-Summary: 1,0,0,d275128bc0fe29ca,d41d8cd98f00b204,willy@infradead.org,,RULES_HIT:41:355:379:421:541:800:960:966:968:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1542:1711:1730:1747:1777:1792:2196:2199:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:4385:4605:5007:6261:6653:7875:7903:8603:10004:11026:11658:11914:12043:12048:12291:12297:12438:12555:12895:12986:13894:14096:14181:14394:14721:21080:21212:21451:21627:21987:21990:30034:30054:30070:30090,0,RBL:90.155.50.34:@infradead.org:.lbl8.mailshell.net-62.8.15.100 64.201.201.201;04ygtyaigo1q5gbftk5etpr81wd51occj1madikqg1h1gakhg4x7qamhyfb93b8.kwxba6cb4peknpcewbbms96hdp1zfeqmijag55sb3jhm1xiqp4ws8qna5oxuwgd.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:70,LUA_SUMMARY:none X-HE-Tag: name81_2a0a0ec272d2 X-Filterd-Recvd-Size: 3673 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Nov 2020 12:30:47 +0000 (UTC) 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=kkDY/A+zQxc2i95QfvhU+XAHKtbfTy4uXu8lLNerbsw=; b=wDr7t34wIJm+GPx9QugRfOlaVv 65UOdzBqP/NbNfJsusEDba3Z6yAvZJD9jiHtHAwu+F9+Kfk8NhxMYlIV3Vongavmd3KbaiLdtlIGM 0CRoZFp9UeM6UQpDaLYqjQFxDWUQCNJdMUxDA4Qu0u+ymSMe8WSaQndx2vKVOxz+RO5Vl7zynUsE3 aiwakoI2jXgS0qYYT9GgFvlFiRMK88Ectkq8+rm/eqNCcSWIfKYS0Q7NQFCyATKHPpR6DueSVPE4D sQnryvoNQe+ag081u66tV7gXmP5JvX+kAmyb3x3nJ/UTo/+zqgTaLWuRmmSNobmUiPVede3UN1pMp kzUFX26w==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb0t8-0007Ql-Fn; Fri, 06 Nov 2020 12:30:42 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, hch@lst.de, kent.overstreet@gmail.com Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 3/4] pagevec: Add dynamically allocated pagevecs Date: Fri, 6 Nov 2020 12:30:39 +0000 Message-Id: <20201106123040.28451-3-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201106123040.28451-1-willy@infradead.org> References: <20201106080815.GC31585@lst.de> <20201106123040.28451-1-willy@infradead.org> MIME-Version: 1.0 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: Add pagevec_alloc() and pagevec_free() to allow for pagevecs up to 255 entries in size. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagevec.h | 7 +++++++ mm/swap.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 4dc45392d776..4d5a48d7a372 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -36,6 +36,13 @@ struct pagevec { void __pagevec_release(struct pagevec *pvec); void __pagevec_lru_add(struct pagevec *pvec); +struct pagevec *pagevec_alloc(unsigned long sz, gfp_t gfp); + +static inline void pagevec_free(struct pagevec *pvec) +{ + kfree(pvec); +} + void pagevec_remove_exceptionals(struct pagevec *pvec); unsigned pagevec_lookup_range_tag(struct pagevec *pvec, diff --git a/mm/swap.c b/mm/swap.c index 1e6f50b312ea..3f856a272cb2 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -988,6 +988,34 @@ void __pagevec_release(struct pagevec *pvec) } EXPORT_SYMBOL(__pagevec_release); +/** + * pagevec_alloc - Allocate a pagevec. + * @sz: Number of pages wanted. + * @gfp: Memory allocation flags. + * + * Allocates a new pagevec. The @sz parameter is advisory; this function + * may allocate a pagevec that can contain fewer pages than requested. If + * the caller cares how many were allocated, it can check pagevec_size(), + * but most callers will simply use as many as were allocated. + * + * Return: A new pagevec, or NULL if memory allocation failed. + */ +struct pagevec *pagevec_alloc(unsigned long sz, gfp_t gfp) +{ + struct pagevec *pvec; + + if (sz > 255) + sz = 255; + pvec = kmalloc_array(sz + 1, sizeof(void *), gfp); + if (!pvec) + return NULL; + pvec->nr = 0; + pvec->sz = sz; + + return pvec; +} +EXPORT_SYMBOL(pagevec_alloc); + #ifdef CONFIG_TRANSPARENT_HUGEPAGE /* used by __split_huge_page_refcount() */ void lru_add_page_tail(struct page *page, struct page *page_tail, From patchwork Fri Nov 6 12:30:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11887065 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0EFF1130 for ; Fri, 6 Nov 2020 12:30:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 962472071A for ; Fri, 6 Nov 2020 12:30:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="QGgesoFq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 962472071A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4307A6B005D; Fri, 6 Nov 2020 07:30:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3B6F66B0068; Fri, 6 Nov 2020 07:30:47 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CDCD6B006C; Fri, 6 Nov 2020 07:30:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id 0040E6B005D for ; Fri, 6 Nov 2020 07:30:46 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A0DE2180AD815 for ; Fri, 6 Nov 2020 12:30:46 +0000 (UTC) X-FDA: 77453927292.15.grape83_6016a4e272d2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 7A2601814B0C8 for ; Fri, 6 Nov 2020 12:30:46 +0000 (UTC) X-Spam-Summary: 1,0,0,32e66db992df9d71,d41d8cd98f00b204,willy@infradead.org,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1515:1534:1542:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3353:3868:5007:6261:6653:7875:9036:10004:11026:11658:11914:12043:12048:12296:12297:12555:12895:13894:14181:14394:14721:21080:21212:21451:21627:21987:21990:30054:30069,0,RBL:90.155.50.34:@infradead.org:.lbl8.mailshell.net-62.8.15.100 64.201.201.201;04ygpp4ffpe61auuq3ara3fgfr8hoypppd4ku8csq738pdqgchm8749jf69ryi3.b3m1tqm8osqe114ig9wyx3nzmpy5fb3txtmmwfyd3tcwqkx61bbczfo1bb8b7su.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:69,LUA_SUMMARY:none X-HE-Tag: grape83_6016a4e272d2 X-Filterd-Recvd-Size: 3880 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Nov 2020 12:30:45 +0000 (UTC) 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=FYfTJc/cRnp3dh2kVQ7v0u0iDrX6gANg53dGJ+BqfQ0=; b=QGgesoFqkX35kbIS61E/vS9DMw nrOfKvHPvDPlMupVmUbr30VyOixlbjuISXTjvoEvLDo9kHtfc3Ry8ZF2v8CAXlZHnDcWrHnA+PMkt ZeuGGhVZaC4/F9vl8iF89cbcXzs1oSYN4N5FUQOdoyIWOPEsyeEtQ19eGzHFQERjW0Y2AgiLoaL13 uF461OmOzcn6MCRt02ce7mHnbZgW8gHhUaLBMgxHE+9HveyzYwOXl0/OPuVwTtJRZIaC+iOJ/aTEP Mgf0UtFim0JjZBJInTLICZK9Yt+FObqAK3ns2T/KM+4C3YykoHjXs66Ggw4gCQbNQyYy0EvkUNz61 lkHyWdsQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb0t8-0007Qr-Oh; Fri, 06 Nov 2020 12:30:42 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, hch@lst.de, kent.overstreet@gmail.com Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 4/4] mm/filemap: Use a dynamically allocated pagevec in filemap_read Date: Fri, 6 Nov 2020 12:30:40 +0000 Message-Id: <20201106123040.28451-4-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201106123040.28451-1-willy@infradead.org> References: <20201106080815.GC31585@lst.de> <20201106123040.28451-1-willy@infradead.org> MIME-Version: 1.0 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: Restore Kent's optimisation for I/O sizes between 64kB and 1MB. Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index f41de0759e86..2b4d8ed241bd 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2427,7 +2427,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, struct file_ra_state *ra = &filp->f_ra; struct address_space *mapping = filp->f_mapping; struct inode *inode = mapping->host; - struct pagevec pvec; + struct pagevec pvec_stack, *pvec = NULL; int i, error = 0; bool writably_mapped; loff_t isize, end_offset; @@ -2436,6 +2436,10 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, return 0; iov_iter_truncate(iter, inode->i_sb->s_maxbytes); + if (iter->count / PAGE_SIZE > PAGEVEC_SIZE) + pvec = pagevec_alloc(iter->count / PAGE_SIZE + 1, GFP_KERNEL); + if (!pvec) + pvec = &pvec_stack; do { cond_resched(); @@ -2447,7 +2451,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, if ((iocb->ki_flags & IOCB_WAITQ) && already_read) iocb->ki_flags |= IOCB_NOWAIT; - error = filemap_get_pages(iocb, iter, &pvec); + error = filemap_get_pages(iocb, iter, pvec); if (error < 0) break; @@ -2476,10 +2480,10 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, */ if (iocb->ki_pos >> PAGE_SHIFT != ra->prev_pos >> PAGE_SHIFT) - mark_page_accessed(pvec.pages[0]); + mark_page_accessed(pvec->pages[0]); - for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < pagevec_count(pvec); i++) { + struct page *page = pvec->pages[i]; size_t page_size = thp_size(page); size_t offset = iocb->ki_pos & (page_size - 1); size_t bytes = min_t(loff_t, end_offset - iocb->ki_pos, @@ -2514,7 +2518,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, } } put_pages: - pagevec_release(&pvec); + pagevec_release(pvec); } while (iov_iter_count(iter) && iocb->ki_pos < isize && !error); file_accessed(filp);