From patchwork Tue Dec 25 02:05:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kehong Zhang X-Patchwork-Id: 10742519 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 77A786C2 for ; Tue, 25 Dec 2018 02:06:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F7FB28AC3 for ; Tue, 25 Dec 2018 02:06:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52B4C28ACB; Tue, 25 Dec 2018 02:06:54 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2C58728AC3 for ; Tue, 25 Dec 2018 02:06:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=HCQVKbDuiIo4P3vhsomUF+h6jPe+v13/KFtzFynUQoI=; b=P5GpWOSA95p7iJ xEjKPtUlxGANgFC8qVZroXCMCYM/vYTMJoDj+O8Ezy/uNqExC4wwV8NqidmuC0wINaY4kaAWXswoz CkFQvC0hvDn3jKnK/8m1mlSZiwevJoXvxftXZ+mdSML32Ql8uF7nrcIYSpcRPCigZ305q30xDmn1s 6FvJ+6TOyFv2kbG1CNDfbPWPcgdspxqxq76xQtKhmBKD0w6tS9sLE6axtjo3awj5wwYXEeK1zHY0l GHVSlOzmIPj/3nkaKHt2OeDgxuDWc+Ocv3HyTiGz7ccohzoKrfxbElyLloJ8e+vqYaoU54EIFTKOG 8/Qg8jSfx+9CXzr2h9ZA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gbc7L-000061-7w; Tue, 25 Dec 2018 02:06:47 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gbc7E-00005C-Fw for linux-arm-kernel@lists.infradead.org; Tue, 25 Dec 2018 02:06:45 +0000 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id D08F1FC6B7B99; Tue, 25 Dec 2018 10:06:19 +0800 (CST) Received: from localhost.localdomain (10.67.212.132) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.408.0; Tue, 25 Dec 2018 10:06:13 +0800 From: Kehong Zhang To: Subject: [RFC] mm: add pad in sturct page Date: Tue, 25 Dec 2018 10:05:03 +0800 Message-ID: <1545703503-20939-1-git-send-email-zhangkehong@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.67.212.132] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181224_180640_709087_C530F76F X-CRM114-Status: GOOD ( 15.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Hocko , Rik van Riel , Marc Zyngier , Catalin Marinas , Will Deacon , Matthew Wilcox , Masahiro Yamada , Vlastimil Babka , Andrey Konovalov , Andrey Ryabinin , Andrew Morton , Kehong Zhang , "Kirill A. Shutemov" , Souptick Joarder Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When I analysis the performance of using nginx for static websites. I found a high cpu workload in the code below: mm/filemap.c @@ 1425,3 @@ struct page *find_get_entry(struct address_space *mapping, pgoff_t offset) head = compound_head(page); if (!page_cache_get_speculative(head)) goto repeat; The code will read page->compound_head and atomic add page->_refcount, which two variables are in the same cache-line. As multiple core read/write two variables in the same cache-line will cause serious slowdown, I test the performance of using nginx for static websites in two cases, add patch below and original. core num\Scenes add pad no pad 8core 317654 344414 As we know, struct page is the most used struct and should be as small as possible. And I don't have a better way to solve it, if anybody have any idea to solve it? Cc: Catalin Marinas Cc: Will Deacon Cc: Andrew Morton Cc: Marc Zyngier Cc: Andrey Ryabinin Cc: Masahiro Yamada Cc: Kehong Zhang Cc: Andrey Konovalov Cc: Matthew Wilcox Cc: "Kirill A. Shutemov" Cc: Vlastimil Babka Cc: Michal Hocko Cc: Souptick Joarder Cc: Rik van Riel Signed-off-by: Kehong Zhang --- arch/arm64/include/asm/memory.h | 2 +- include/linux/mm_types.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index b9644296..652ccf6 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -41,7 +41,7 @@ * requires its definition to be available at this point in the inclusion * chain, and it may not be a power of 2 in the first place. */ -#define STRUCT_PAGE_MAX_SHIFT 6 +#define STRUCT_PAGE_MAX_SHIFT 8 /* * VMEMMAP_SIZE - allows the whole linear region to be covered by diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 5ed8f62..0a11c5b 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -179,6 +179,8 @@ struct page { int units; /* SLOB */ }; + unsigned char pad[128]; + /* Usage count. *DO NOT USE DIRECTLY*. See page_ref.h */ atomic_t _refcount;