From patchwork Mon Oct 15 20:26:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10642441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0517A15E2 for ; Mon, 15 Oct 2018 20:27:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8ECF28C56 for ; Mon, 15 Oct 2018 20:27:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBD4729FAB; Mon, 15 Oct 2018 20:27:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5625928C56 for ; Mon, 15 Oct 2018 20:27:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 465296B000A; Mon, 15 Oct 2018 16:27:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 414256B000C; Mon, 15 Oct 2018 16:27:00 -0400 (EDT) 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 2B68C6B000D; Mon, 15 Oct 2018 16:27:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id DA2526B000A for ; Mon, 15 Oct 2018 16:26:59 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id s15-v6so15597800pgv.9 for ; Mon, 15 Oct 2018 13:26:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=suWn29q/ZTe1RiXl1jWK2FZZ+lm3Ho4T+G4S9Sb2D9s=; b=SDtYINWYeZgYmCUWO8MWqxK+Lh2Thiyj0OrKd/st8jxBY4zEaxpWe6TN+DjiO7MjFG cmr7ddcSatDJk9ryM9qxJYJM0r5ykiC/PMC7J/adDY/PRbo+/xFZ1jYsnKgoe+dJMmCy GNx85oKwm07n9FCeiObVcFf2/fDrm2MaptGjwbZow8cN6rZpln6I6KaIneN/An933rc1 q07ebxZGCya6Py5iZkVFfTbrYqypmcL553sczfXI2Byv0D93kInNvrrymr/iyR5ux7UR 4H0k6o+//jvCbe379sREUdGPzIO9EdOjWP1nkfSavgxTtdcbegeYW112wz2j3qfcGSO9 /VbQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ABuFfoggRfggtNZQ2KFA3kyUbuzMpU4QO8HmRZpaHTOcKu0riX1ZeGSo usZ8VeXKuEzp/nFGcwQ6oLSmjUSjDNTetiZQzDIL5kHDGhbVwp6G94xLdBgcFBfWfLvFGl7H5sS UNPqibVapK5VZ6CLfoeIKlvwKYMgRP7kK40XcGO9dwpr2zx8iHhCOWABsA5UQto4tZg== X-Received: by 2002:a63:a54f:: with SMTP id r15-v6mr17470073pgu.176.1539635219515; Mon, 15 Oct 2018 13:26:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV61L82y5yN7c11vmou7bXGd65wuiXvE+Jbwyr4iPQd7Gal5V9otH+L+OJKuowNbJLWftN3dH X-Received: by 2002:a63:a54f:: with SMTP id r15-v6mr17470030pgu.176.1539635218570; Mon, 15 Oct 2018 13:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539635218; cv=none; d=google.com; s=arc-20160816; b=Vs/Ikyoh3v4pKVKc9NI3higPr46I1UlxMqngr+amJeRm1D5WbdVToeNmIYK1w6Bq2b tCQbwknW0ld1hgYEWQsfcR/DMq9yzT8/sh94jPiRrzcTSfXF3arwQM4lB3UaOaEZKbxU KFu2C1sWPqsVLfyPpN3pkCuMWisv+h96cry4hZOiPeG+ZUFY0MaCmTCrCmvsJU/5uiP9 o18BXnAaOf5WyqNw19FUoSpY5bQ/XT+svMt6MpBqa6mTKvT62NEcibqVcpSzIp6xG4TG 2M/Pb0qgezImBT4dp5wr7mbQPzd6d0SlpdeHHNdt8wBdbx/zhC+C/agT1uwo9DdmPOZS Lxzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=suWn29q/ZTe1RiXl1jWK2FZZ+lm3Ho4T+G4S9Sb2D9s=; b=V5dufNkvZmhAlVldK6DYy3nnr1BjefabYvWxN++ig2soCxI5Sa3/RqVlUoMMpZX1M6 54MR+wM4P/5rvo42mKUTBwU/kV50gZ+2GZxec0u1+0fUmC6z0PR9vJmEANaV9NhBvAd9 5Y1Gkzfs90aM0ndoVuCMVoi9cCJPn//wJRUn8EjnJ3M0zpkh870L+InOePMslVyi7JT3 nIfSjI2LX8Z2nOz3Qxp759HiFetzhziCCwNfgTc5T6Xj7hLIXoAUx7H9HVAdghvMHWOp iwrtuPQHueoT8Ne4ZXJENoUs20i+kSdWdLCoBPG6bjMODLpHFrmgBdZ5CFRJJsJK7AGx nX8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga02.intel.com (mga02.intel.com. [134.134.136.20]) by mx.google.com with ESMTPS id w9-v6si11424155pll.138.2018.10.15.13.26.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 13:26:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.20 as permitted sender) client-ip=134.134.136.20; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Oct 2018 13:26:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,385,1534834800"; d="scan'208";a="92202439" Received: from ahduyck-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.7.198.154]) by orsmga003.jf.intel.com with ESMTP; 15 Oct 2018 13:26:56 -0700 Subject: [mm PATCH v3 1/6] mm: Use mm_zero_struct_page from SPARC on all 64b architectures From: Alexander Duyck To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: pavel.tatashin@microsoft.com, mhocko@suse.com, dave.jiang@intel.com, alexander.h.duyck@linux.intel.com, linux-kernel@vger.kernel.org, willy@infradead.org, davem@davemloft.net, yi.z.zhang@linux.intel.com, khalid.aziz@oracle.com, rppt@linux.vnet.ibm.com, vbabka@suse.cz, sparclinux@vger.kernel.org, dan.j.williams@intel.com, ldufour@linux.vnet.ibm.com, mgorman@techsingularity.net, mingo@kernel.org, kirill.shutemov@linux.intel.com Date: Mon, 15 Oct 2018 13:26:56 -0700 Message-ID: <20181015202656.2171.92963.stgit@localhost.localdomain> In-Reply-To: <20181015202456.2171.88406.stgit@localhost.localdomain> References: <20181015202456.2171.88406.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty 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: X-Virus-Scanned: ClamAV using ClamSMTP This change makes it so that we use the same approach that was already in use on Sparc on all the archtectures that support a 64b long. This is mostly motivated by the fact that 8 to 10 store/move instructions are likely always going to be faster than having to call into a function that is not specialized for handling page init. An added advantage to doing it this way is that the compiler can get away with combining writes in the __init_single_page call. As a result the memset call will be reduced to only about 4 write operations, or at least that is what I am seeing with GCC 6.2 as the flags, LRU poitners, and count/mapcount seem to be cancelling out at least 4 of the 8 assignments on my system. One change I had to make to the function was to reduce the minimum page size to 56 to support some powerpc64 configurations. Signed-off-by: Alexander Duyck --- arch/sparc/include/asm/pgtable_64.h | 30 ------------------------------ include/linux/mm.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index 1393a8ac596b..22500c3be7a9 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -231,36 +231,6 @@ extern struct page *mem_map_zero; #define ZERO_PAGE(vaddr) (mem_map_zero) -/* This macro must be updated when the size of struct page grows above 80 - * or reduces below 64. - * The idea that compiler optimizes out switch() statement, and only - * leaves clrx instructions - */ -#define mm_zero_struct_page(pp) do { \ - unsigned long *_pp = (void *)(pp); \ - \ - /* Check that struct page is either 64, 72, or 80 bytes */ \ - BUILD_BUG_ON(sizeof(struct page) & 7); \ - BUILD_BUG_ON(sizeof(struct page) < 64); \ - BUILD_BUG_ON(sizeof(struct page) > 80); \ - \ - switch (sizeof(struct page)) { \ - case 80: \ - _pp[9] = 0; /* fallthrough */ \ - case 72: \ - _pp[8] = 0; /* fallthrough */ \ - default: \ - _pp[7] = 0; \ - _pp[6] = 0; \ - _pp[5] = 0; \ - _pp[4] = 0; \ - _pp[3] = 0; \ - _pp[2] = 0; \ - _pp[1] = 0; \ - _pp[0] = 0; \ - } \ -} while (0) - /* PFNs are real physical page numbers. However, mem_map only begins to record * per-page information starting at pfn_base. This is to handle systems where * the first physical page in the machine is at some huge physical address, diff --git a/include/linux/mm.h b/include/linux/mm.h index bb0de406f8e7..ec6e57a0c14e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -102,8 +102,42 @@ static inline void set_max_mapnr(unsigned long limit) { } * zeroing by defining this macro in . */ #ifndef mm_zero_struct_page +#if BITS_PER_LONG == 64 +/* This function must be updated when the size of struct page grows above 80 + * or reduces below 64. The idea that compiler optimizes out switch() + * statement, and only leaves move/store instructions + */ +#define mm_zero_struct_page(pp) __mm_zero_struct_page(pp) +static inline void __mm_zero_struct_page(struct page *page) +{ + unsigned long *_pp = (void *)page; + + /* Check that struct page is either 56, 64, 72, or 80 bytes */ + BUILD_BUG_ON(sizeof(struct page) & 7); + BUILD_BUG_ON(sizeof(struct page) < 56); + BUILD_BUG_ON(sizeof(struct page) > 80); + + switch (sizeof(struct page)) { + case 80: + _pp[9] = 0; /* fallthrough */ + case 72: + _pp[8] = 0; /* fallthrough */ + default: + _pp[7] = 0; /* fallthrough */ + case 56: + _pp[6] = 0; + _pp[5] = 0; + _pp[4] = 0; + _pp[3] = 0; + _pp[2] = 0; + _pp[1] = 0; + _pp[0] = 0; + } +} +#else #define mm_zero_struct_page(pp) ((void)memset((pp), 0, sizeof(struct page))) #endif +#endif /* * Default maximum number of active map areas, this limits the number of vmas