From patchwork Fri Mar 24 16:13:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 9643209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 479DF60327 for ; Fri, 24 Mar 2017 16:14:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3898C20223 for ; Fri, 24 Mar 2017 16:14:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D3F02623C; Fri, 24 Mar 2017 16:14:51 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 C979720223 for ; Fri, 24 Mar 2017 16:14:50 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=6GqdXUfWTsW/1GUa18VK5jJD/233JaHv5XPK6QgqW2Q=; b=K0szVwTo2EKYzKW2OsPf/tCj4A 7Qa9OavjiB/yutFqdIa+AI69aqdSgOOotJ5xo5eOLYez4tKlq6tsW+uhSDVrr3ShvB9lGqN6Z1u3E JUyEyT2pS2xbf/abZjYquaHFdnhsebs3pIlEaYBFlUFss6eBRNSzpZlvwAmaiHSdC3K3nvZgJUvPe LmTFa17ee7jMeFUGNbGHyO+W96SfMZSwkOX5hyCFR/DXcT5eVvuE+9J4PXFr/2qvR91Ne9+YwJgPm 9r9E/LpRH0FO0zoWiE9+2lC5DrKCXHz6kZ/RIfwa/2QGSU224j8cCc2MRSNhAsUJyctbkn0T+8asL /D5BrhVQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1crRrV-0006Vi-Q7; Fri, 24 Mar 2017 16:14:49 +0000 Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1crRqK-0004v9-Ju; Fri, 24 Mar 2017 16:13:36 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Subject: [PATCH v3 5/7] zram: Convert to using memset_l Date: Fri, 24 Mar 2017 09:13:16 -0700 Message-Id: <20170324161318.18718-6-willy@infradead.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170324161318.18718-1-willy@infradead.org> References: <20170324161318.18718-1-willy@infradead.org> 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: linux-arch@vger.kernel.org, linux-mips@linux-mips.org, linux-fbdev@vger.kernel.org, Matthew Wilcox , x86@kernel.org, Minchan Kim , linux-alpha@vger.kernel.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 From: Matthew Wilcox zram was the motivation for creating memset_l(). Minchan Kim sees a 7% performance improvement on x86 with 100MB of non-zero deduplicatable data: perf stat -r 10 dd if=/dev/zram0 of=/dev/null vanilla: 0.232050465 seconds time elapsed ( +- 0.51% ) memset_l: 0.217219387 seconds time elapsed ( +- 0.07% ) Signed-off-by: Matthew Wilcox Tested-by: Minchan Kim Acked-by: Minchan Kim --- drivers/block/zram/zram_drv.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index e27d89a36c34..25dcad309695 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -157,20 +157,11 @@ static inline void update_used_max(struct zram *zram, } while (old_max != cur_max); } -static inline void zram_fill_page(char *ptr, unsigned long len, +static inline void zram_fill_page(void *ptr, unsigned long len, unsigned long value) { - int i; - unsigned long *page = (unsigned long *)ptr; - WARN_ON_ONCE(!IS_ALIGNED(len, sizeof(unsigned long))); - - if (likely(value == 0)) { - memset(ptr, 0, len); - } else { - for (i = 0; i < len / sizeof(*page); i++) - page[i] = value; - } + memset_l(ptr, value, len / sizeof(unsigned long)); } static bool page_same_filled(void *ptr, unsigned long *element) @@ -193,7 +184,7 @@ static bool page_same_filled(void *ptr, unsigned long *element) static void handle_same_page(struct bio_vec *bvec, unsigned long element) { struct page *page = bvec->bv_page; - void *user_mem; + char *user_mem; user_mem = kmap_atomic(page); zram_fill_page(user_mem + bvec->bv_offset, bvec->bv_len, element);