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 X-Patchwork-Id: 9643197 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 E10C660327 for ; Fri, 24 Mar 2017 16:14:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2EEC2521E for ; Fri, 24 Mar 2017 16:14:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7B9120223; Fri, 24 Mar 2017 16:14:07 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A32720223 for ; Fri, 24 Mar 2017 16:14:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966165AbdCXQOE (ORCPT ); Fri, 24 Mar 2017 12:14:04 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:59447 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966142AbdCXQNp (ORCPT ); Fri, 24 Mar 2017 12:13:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=iwCTDw1gKmaip942Vra7u7vH5dYa0pxQj9ZXMAP62io=; b=aCW+iwBWqWs7jo2FYtWqb4x8J yQLTZPTjK8V/Zs4qPXEZIgwj7Hocrp05wbd2v3Pg2fGwrPWr2fzg5ApbPiTMTD2AMQt72MGCE/Dcg gFMr9XluEYM3P9lwF+lm6k0kdEBVjFisF9hbXMsd+gGA8uiEpD8enqf8ftiwzUVw7WwZQ4XwdwGg6 bBFQp12+0UcBkfWD0pLZAw4R2ajZiRz7cVw4GV/JeGwY1HEOM4BXuYi/lf0zo72goc40NgAuO+kA1 Mm9zK/lCJDIMjErWTJcUamQSpppiIxT1rddyVABmPyuGXaidurHLVRch/tVfeQVkL82mVrNFKyXXe gpmnEtBEg==; 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 Cc: linux-fbdev@vger.kernel.org, linux-arch@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-mips@linux-mips.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, Minchan Kim , Matthew Wilcox 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> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.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);