From patchwork Thu Oct 11 22:13:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10637523 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 D7288157A for ; Thu, 11 Oct 2018 22:17:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0E722C1FB for ; Thu, 11 Oct 2018 22:17:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2B752C205; Thu, 11 Oct 2018 22:17:02 +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 29E482C207 for ; Thu, 11 Oct 2018 22:17:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CCBE6B0005; Thu, 11 Oct 2018 18:16:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 27B986B0006; Thu, 11 Oct 2018 18:16:58 -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 169D46B0008; Thu, 11 Oct 2018 18:16:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id C93F86B0005 for ; Thu, 11 Oct 2018 18:16:57 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id r16-v6so7585982pgv.17 for ; Thu, 11 Oct 2018 15:16:57 -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=E0WoVFiUqIIn0PLhGSCojsTtJfbPFdXSCo9wmfd4jsg=; b=YSJnYSZUP+Vfq4Y3F4jdPyLS+SSfxQ0nmDd7haq1G0R/tmb9sGUa7yk5J+v9TqhZUY wrliiLwjtiBDzKzDjwWqP19uUXcp3BjybKJd87be6cz0Rie8y3IAJfLE8yqzX+9B1M0D kNYihzaC6pwJD2obwvh2zvRkuJnf6rQdLXux2Wg3/i3e+4d/DQ0C/C/hirsiaH3378Nd YTFk73wkBogoewNkbYyOOGTWW/jClePr7FcmXhk/dsN6AhXaOATew9oZX5LD7/4WA03U CT2fLD6u5wa1dYZ5MuyBT69wOBEdZ1I4Fv6gYcuwu4iuANaDB0QWE4kCkVdqcK9E04ho CHcA== 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.126 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: ABuFfoilH+9M+wQINzwCYbh2fnyRFErbsdN4Ws/EP0rvBnvQLL0wUy0P A/N1rjQjwMfeiXYkHQhrP/m4izs11m/73Vy0rCwJW6yavToKoF0H9CqzbsYon/f3YZayMYKdV6e kRsLlftc/uftLCdPS6s79VsbrwG9in1Z4WZG1SViO5xocbK2WOJ3ZvD+TpEqjunvOrw== X-Received: by 2002:a63:3842:: with SMTP id h2-v6mr3037251pgn.300.1539296217454; Thu, 11 Oct 2018 15:16:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV631WdEn8UWE9/lc+wj7HnCqkDAeS/IqmNSn1uC9KFcJM9DWDW5nUOUA8fgvclflHEW3j+pk X-Received: by 2002:a63:3842:: with SMTP id h2-v6mr3037200pgn.300.1539296216366; Thu, 11 Oct 2018 15:16:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539296216; cv=none; d=google.com; s=arc-20160816; b=yP8Hln2tXi6bNTrHgbv//gmbWitgTw6kJKehUhWNsRh/bGFvSJ8GHlaPGKccfGlib9 fiz6JYpH6orOhqZ1VNxGhbUrNZmdebj159nHPFrHz1b2F5yWP9yScPwRjoziqfq0wMAn 84IC5lhmTZqigqzAqutTQOw9w9USTfPsRdTmh0sjrxtW35l5WQ7IG6G4LNDFlWP9pdpU 45A6uGt9F4Qc6LILCrE9vadPfgJDDUaQXVHR7xrYLXhs4XCp3qdNlN8Yv00Q1td7EqIZ uBkUA75Fmxs5sFLCMK4735qjPNarVQQ4eC9WlgeWLyyr+4BakD0WfoYKBXVeCY23G+FX Qvpg== 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=E0WoVFiUqIIn0PLhGSCojsTtJfbPFdXSCo9wmfd4jsg=; b=tca9AN+zAmddZ1s65YogU4u76SrOJbUss3xzFqsT/gAnRumlIxUGu07nUthfn+Mkos cFpCIx7jnuVinde2i7ImcyBsHcToq4iC5e38lcgx+eb1fyCKXy959o1Sz3nM8qhcvIkg fp89aObABo1VPqDC92jJ2iFF4md2806+F6KGP+Dfgn/9jRKfEiRVwWj0GGVHvyRKAZzj ekbPeNlnXZLSWWNkZBUXUn12EqS/PTyqSu9XJPaEAHLUDtROJtDQuXyb7XkVQ1Y1ufzd dMsGMVxpb0Fgtln6Ra+GjpVtjrXA/CpjhK3g4BZiAi292gml0qa9W6Le/c3PQwdb8+fD pPHw== 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.126 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 mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id r29-v6si24916614pff.262.2018.10.11.15.16.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 15:16:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; 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.126 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 orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 15:16:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,370,1534834800"; d="scan'208";a="80765698" Received: from ahduyck-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.7.198.157]) by orsmga008.jf.intel.com with ESMTP; 11 Oct 2018 15:13:34 -0700 Subject: [mm PATCH v2 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: Thu, 11 Oct 2018 15:13:34 -0700 Message-ID: <20181011221334.1925.31961.stgit@localhost.localdomain> In-Reply-To: <20181011221237.1925.85591.stgit@localhost.localdomain> References: <20181011221237.1925.85591.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 273d4dbd3883..dee407998366 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