From patchwork Sun Dec 1 01:51:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11268259 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 09D30112B for ; Sun, 1 Dec 2019 01:51:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C0F2B215E5 for ; Sun, 1 Dec 2019 01:51:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZLxG2cNW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C0F2B215E5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 585036B02A8; Sat, 30 Nov 2019 20:51:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 55DC26B02AA; Sat, 30 Nov 2019 20:51:22 -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 424906B02AB; Sat, 30 Nov 2019 20:51:22 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id 2C3706B02A8 for ; Sat, 30 Nov 2019 20:51:22 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id DA3B2824999B for ; Sun, 1 Dec 2019 01:51:21 +0000 (UTC) X-FDA: 76214895162.20.twig06_bdf81d019330 X-Spam-Summary: 2,0,0,4bc6524e3ecaf1be,d41d8cd98f00b204,akpm@linux-foundation.org,:akpm@linux-foundation.org:aneesh.kumar@linux.ibm.com:arnd@arndb.de:kirill.shutemov@linux.intel.com::mm-commits@vger.kernel.org:npiggin@gmail.com:peterz@infradead.org:torvalds@linux-foundation.org:vgupta@synopsys.com:vineet.gupta1@synopsys.com:will@kernel.org,RULES_HIT:41:355:379:800:960:966:967:968:973:988:989:1260:1263:1345:1381:1431:1437:1534:1542:1711:1730:1747:1777:1792:1801:1978:1981:2194:2196:2199:2200:2393:2525:2559:2563:2682:2685:2693:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4385:4605:5007:6119:6261:6653:6737:7208:7514:7576:7903:7904:7974:8599:8784:9025:9113:9121:9545:10004:10913:11026:11473:11658:11914:12043:12048:12114:12295:12297:12438:12517:12519:12555:12679:12783:12986:13255:13846:14181:14721:14849:21080:21451:21627:21939:30012:30054,0,RBL:error,Cach eIP:none X-HE-Tag: twig06_bdf81d019330 X-Filterd-Recvd-Size: 4114 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Sun, 1 Dec 2019 01:51:21 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6E4B82084E; Sun, 1 Dec 2019 01:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575165080; bh=oy0j8etxcASYVIOiIT9WcHyDlXpOfrWG08HrLcdEfl0=; h=Date:From:To:Subject:From; b=ZLxG2cNW/vR0sw+tdHBEsJj5aHzpDR88+pZ8TAMjx74KyAZBKGn1j/tmC1d67NyOI qokxlMqpcjB12tJc+FjRIlHgUQx8Tf6wZgJHA85OrQwjnW6qPvpCNPupIWAxHLmfwC AliGdJBy7CQpIcK3fFaY8Wmh7NOpMXaHjzDoiaIA= Date: Sat, 30 Nov 2019 17:51:20 -0800 From: akpm@linux-foundation.org To: akpm@linux-foundation.org, aneesh.kumar@linux.ibm.com, arnd@arndb.de, kirill.shutemov@linux.intel.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, npiggin@gmail.com, peterz@infradead.org, torvalds@linux-foundation.org, vgupta@synopsys.com, Vineet.Gupta1@synopsys.com, will@kernel.org Subject: [patch 041/158] asm-generic/mm: stub out p{4,u}d_clear_bad() if __PAGETABLE_P{4,U}D_FOLDED Message-ID: <20191201015120.r8GhpSk1Y%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 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: From: Vineet Gupta Subject: asm-generic/mm: stub out p{4,u}d_clear_bad() if __PAGETABLE_P{4,U}D_FOLDED This came up when removing __ARCH_HAS_5LEVEL_HACK for ARC as code bloat. With this patch we see the following code reduction. | bloat-o-meter2 vmlinux-D-elide-p4d_free_tlb vmlinux-E-elide-p?d_clear_bad | add/remove: 0/2 grow/shrink: 0/0 up/down: 0/-40 (-40) | function old new delta | pud_clear_bad 20 - -20 | p4d_clear_bad 20 - -20 | Total: Before=4136930, After=4136890, chg -1.000000% Link: http://lkml.kernel.org/r/20191016162400.14796-6-vgupta@synopsys.com Signed-off-by: Vineet Gupta Acked-by: Kirill A. Shutemov Cc: Arnd Bergmann Cc: Will Deacon Cc: "Aneesh Kumar K . V" Cc: Nick Piggin Cc: Peter Zijlstra Cc: Linus Torvalds Signed-off-by: Andrew Morton --- include/asm-generic/pgtable.h | 11 +++++++++++ mm/pgtable-generic.c | 9 +++++++++ 2 files changed, 20 insertions(+) --- a/include/asm-generic/pgtable.h~asm-generic-mm-stub-out-p4ud_clear_bad-if-__pagetable_p4ud_folded +++ a/include/asm-generic/pgtable.h @@ -558,8 +558,19 @@ static inline pgprot_t pgprot_modify(pgp * Do the tests inline, but report and clear the bad entry in mm/memory.c. */ void pgd_clear_bad(pgd_t *); + +#ifndef __PAGETABLE_P4D_FOLDED void p4d_clear_bad(p4d_t *); +#else +#define p4d_clear_bad(p4d) do { } while (0) +#endif + +#ifndef __PAGETABLE_PUD_FOLDED void pud_clear_bad(pud_t *); +#else +#define pud_clear_bad(p4d) do { } while (0) +#endif + void pmd_clear_bad(pmd_t *); static inline int pgd_none_or_clear_bad(pgd_t *pgd) --- a/mm/pgtable-generic.c~asm-generic-mm-stub-out-p4ud_clear_bad-if-__pagetable_p4ud_folded +++ a/mm/pgtable-generic.c @@ -24,18 +24,27 @@ void pgd_clear_bad(pgd_t *pgd) pgd_clear(pgd); } +#ifndef __PAGETABLE_P4D_FOLDED void p4d_clear_bad(p4d_t *p4d) { p4d_ERROR(*p4d); p4d_clear(p4d); } +#endif +#ifndef __PAGETABLE_PUD_FOLDED void pud_clear_bad(pud_t *pud) { pud_ERROR(*pud); pud_clear(pud); } +#endif +/* + * Note that the pmd variant below can't be stub'ed out just as for p4d/pud + * above. pmd folding is special and typically pmd_* macros refer to upper + * level even when folded + */ void pmd_clear_bad(pmd_t *pmd) { pmd_ERROR(*pmd);