From patchwork Sat Aug 19 03:18: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: 13358456 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 BF28DEE499C for ; Sat, 19 Aug 2023 03:18:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1899828006B; Fri, 18 Aug 2023 23:18:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13B6D900004; Fri, 18 Aug 2023 23:18:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 027FD28006B; Fri, 18 Aug 2023 23:18:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E3C51900004 for ; Fri, 18 Aug 2023 23:18:50 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A9F83A08B9 for ; Sat, 19 Aug 2023 03:18:50 +0000 (UTC) X-FDA: 81139397220.14.DE84A4F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id 22F761C0005 for ; Sat, 19 Aug 2023 03:18:47 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RBgiaw3+; dmarc=none; spf=none (imf18.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=1692415128; 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:references:dkim-signature; bh=IIFXsg09iSxjFnHhnkEBA+Y8UV0ucdMwpRB+wG9lKEE=; b=Xs/cjjSsBEU5gucwj/e8IxL+BA/ezgpPerg4YmYZOKvGfI1bTMJaB5/wGHadpGXClHpjtv ZEKi7+qztKozGo0x3NfM8EOb1p7rNAPNcGTVmuAT94MgAAaMZOpo/V+s3IBzZPmZt0YXir cxiXRUTUcKubANVK/Obczhj4zJEWhGI= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RBgiaw3+; dmarc=none; spf=none (imf18.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=1692415128; a=rsa-sha256; cv=none; b=kY9FHP8tZP/Rfq6CfcCFItaKaFKu4Reajw+qcHfUr3/lQr9fCSdjda/55xsdvClcJiWFY+ 6ppHEDLi5TRe5Jhl9FIO749CnfpTHGBJ7iONGmeu81HOu7QmUcTfTYBPNjXGDQjr8Aiho9 /8XgwdFJQHEuoG4ZXFVMfrMpyBssM80= 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: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=IIFXsg09iSxjFnHhnkEBA+Y8UV0ucdMwpRB+wG9lKEE=; b=RBgiaw3+qO3thcEpMDzdQHjjV8 Hfr6ZcM4qvZGuHc5utpxR+pySLZAS75XwMByQBaJCYFuqlksM6uIV3/4lW8S+1bRlbgc6RM5QfVMQ SR/ilQKGSpM9iXUuQEN8SJoSxzinLwzqlXDCPA3fCjJU5t0/69B/2DrAfR4nEh+DzCV8P3lAH+lFV 84J9Ml21o9DKZv9Vk536w1EdFMFTVZZxRwW4cCHMtk903SZcgn/becoh7UWrHD5hzCCTTy7CFd79B GbuW6tWIgO0HKN5qYrtVFoJBXMESneKEOEKbI19BCNZ5FQANctTP0VmQOt90sPvo75M5M2BC5hE71 uK2/0+mA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qXCU9-00DG6z-8g; Sat, 19 Aug 2023 03:18:45 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Mike Rapoport , Christian Dietrich Subject: [PATCH] mm: Remove checks for pte_index Date: Sat, 19 Aug 2023 04:18:37 +0100 Message-Id: <20230819031837.3160096-1-willy@infradead.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 22F761C0005 X-Stat-Signature: n7bwz15xocfa6ed1fme71d8cn9n937j8 X-HE-Tag: 1692415127-831888 X-HE-Meta: U2FsdGVkX1/ahL/opGTU2qIE2Rj+U6ZBksRLbkwXAa4gT4Oy2W49111dWdD+qpFJu83XI4inJPuyA7axF9VdUQaJdCPPfg1mwWCkpsWPj9b0lh4jHXR4ZonNy2hEq0GiyHJ7PM6ur0jn+toGyG0M9zCRVgpen2l9UTq6PFxBnXGptjuwRFJIuqjSR0L/dtAVizdQubEpI1nuFH5JV9YtOSyLzDUq9X8oWHX+PFNmawnvMUBDlYC/m7jxa5EQ8ciiRTUW2vtGbCOnahtACwi9Q1T88UGeVIuR4xPM2Lk2Ty8ahBC/n22pB0gGk7x8AOKVIM9sKQtW3NGCavfHVDXFy+cQkM54Bsb5+FKzvYitOKnmolqyGR0tMWBKoBoElo39SFNKinFeTzWhJ1Us+zRBs/z/Qiw8SwthOKkwRo8CUC1MpO4hQ02WimnUJ0zI9yWiBAfpxIH/qBeWPHeKSmOj4dn/MsrnmOBfFBvtw6GWvpA+Lxw5cy7bdV5m+DBdY0F3eZP34UcRYU24NQU5kxlT1cg5a2g0QmBXjFXdDQF/PGE+InhOjnb2Fd5I2kKkcX97lpOh0VKq/P3CsaVl7jqEOo5xsN1rQ7nW/ZnQwQPceXIeMsnVmxf/I8AjOLRbHWWe30JKnIs4ECEFm73kiM05J48T2bbtd7FCK9EjjjWqDySIW6n1CAQsTk/1+gUQ5X2i+9sMepZyLI9Ueo5UUBWONIqBH/X1IdRxKHU7Vifm82NN6Opt/EhpIV5jtdI2gFYX1osmpf2r2to1PhPB5W0h7DQHqPlwGnBZKggjdLuwHJ4N5HWtWjfmkyplMjZ/asUg4CmZzS36MECmie/O6KFSxn2EWYA/dAaUEeNL1GOLtMf322B8Gh58cR+G5VjMB+lzTX5p+wr50NEnslh5on6PQbTRnDrxlApG5JPK2lPa9IAdAGLK7MOh4P8G/okzGy5/jhCp4Q2XoPnnlCwSL3I SWbFK7Cb pO3PCkPVip03rvRNbXs711zgTcsR+rzriSufRC1GNr3jk7xwVHOiNs1mCmBZHBbTHLm3LNstiX+BNAIp/DywpsLLckaPF0riZBzW/CVZpkh48FexISq5KiTskxfh41+Bl7Au0mm/2eD/Eb0ghju/pWlou8KGFDZ3eJDzQzgjVW0Tmzmywq9iWWot62mmPpMxsNumKDQYjjJBoJgHmRrsKZrU0CSunVzyuie/qRsQPS+Oft9pCTCA6bxo2pQ== 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: Since pte_index is always defined, we don't need to check whether it's defined or not. Delete the slow version that doesn't depend on it and remove the #define since nobody needs to test for it. Signed-off-by: Matthew Wilcox (Oracle) Cc: Mike Rapoport Cc: Christian Dietrich Reviewed-by: Mike Rapoport (IBM) --- include/linux/pgtable.h | 1 - mm/memory.c | 17 +---------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index cb5c1fad1078..1fba072b3dac 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -66,7 +66,6 @@ static inline unsigned long pte_index(unsigned long address) { return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); } -#define pte_index pte_index #ifndef pmd_index static inline unsigned long pmd_index(unsigned long address) diff --git a/mm/memory.c b/mm/memory.c index 2947fbc558f6..b7ce04cb058d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1870,7 +1870,6 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, return retval; } -#ifdef pte_index static int insert_page_in_batch_locked(struct vm_area_struct *vma, pte_t *pte, unsigned long addr, struct page *page, pgprot_t prot) { @@ -1885,7 +1884,7 @@ static int insert_page_in_batch_locked(struct vm_area_struct *vma, pte_t *pte, } /* insert_pages() amortizes the cost of spinlock operations - * when inserting pages in a loop. Arch *must* define pte_index. + * when inserting pages in a loop. */ static int insert_pages(struct vm_area_struct *vma, unsigned long addr, struct page **pages, unsigned long *num, pgprot_t prot) @@ -1944,7 +1943,6 @@ static int insert_pages(struct vm_area_struct *vma, unsigned long addr, *num = remaining_pages_total; return ret; } -#endif /* ifdef pte_index */ /** * vm_insert_pages - insert multiple pages into user vma, batching the pmd lock. @@ -1964,7 +1962,6 @@ static int insert_pages(struct vm_area_struct *vma, unsigned long addr, int vm_insert_pages(struct vm_area_struct *vma, unsigned long addr, struct page **pages, unsigned long *num) { -#ifdef pte_index const unsigned long end_addr = addr + (*num * PAGE_SIZE) - 1; if (addr < vma->vm_start || end_addr >= vma->vm_end) @@ -1976,18 +1973,6 @@ int vm_insert_pages(struct vm_area_struct *vma, unsigned long addr, } /* Defer page refcount checking till we're about to map that page. */ return insert_pages(vma, addr, pages, num, vma->vm_page_prot); -#else - unsigned long idx = 0, pgcount = *num; - int err = -EINVAL; - - for (; idx < pgcount; ++idx) { - err = vm_insert_page(vma, addr + (PAGE_SIZE * idx), pages[idx]); - if (err) - break; - } - *num = pgcount - idx; - return err; -#endif /* ifdef pte_index */ } EXPORT_SYMBOL(vm_insert_pages);