From patchwork Wed May 23 06:47:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Guo X-Patchwork-Id: 918798 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40rPSj6C6vz9s16 for ; Wed, 23 May 2018 17:35:49 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uPrG84F7"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40rPSj3tgVzF0cy for ; Wed, 23 May 2018 17:35:49 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uPrG84F7"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::243; helo=mail-pf0-x243.google.com; envelope-from=wei.guo.simon@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uPrG84F7"; dkim-atps=neutral Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40rPPW5FsQzDrph for ; Wed, 23 May 2018 17:33:03 +1000 (AEST) Received: by mail-pf0-x243.google.com with SMTP id o76-v6so10051769pfi.5 for ; Wed, 23 May 2018 00:33:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tDljfwguQ8GbRa/FuvdNEC6OpXATY83L0FN3JYGYPyg=; b=uPrG84F7Wd15KMJxmdL8PB3mfU8Fo28SMcnpHE8lA0NVXSfnk6mMzKQRwkEXjZ5Oy5 gNdJ7ir6ueEdu7iHiAAvpwLrryBWCKzDcM/l22+C7tmI+pl0E6GTLQyJhYd9XPMepeYC XVpb+WC7uma7UkJdFpfiojkPOlo4iloeBdv47QfJr7iQqOmIbwWOlb/C+Ndrp7nwT/io HDmmUpxeRPf9StXnHlc1tkXgnT94n9yOOppC39mv+nZnD62Ofrrdu1WDklSQWZPcIPh3 lPdeMBF1I6eIk2H7Hns1WpxFWcevPcq0Y74t+wBSYjy8wRABiKmsQSZDU/Uk5H88ta1f v/Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tDljfwguQ8GbRa/FuvdNEC6OpXATY83L0FN3JYGYPyg=; b=r8jVkH7x55P+5Wc9w5Q6pTYs+mR6BwUhD3/SXB8HT1c+Jt31MlxUTRVv+bUCCRzmhu YLUuoi64MHsqQwx/z37iBcAIz8tAuEPEfHFMCa06kLzQSInIZKLXKGJHIbmXUz/SqF/d g4+rmjjvjLStSdUcKfLZIE583SXWZur1LVV9Cs8sc99meY9lw5iGJn/NSWELy81Z77ng bFHXrfb3Lxo+5VUTs5lKtyi4box9PmQPGbfSx9MIDeXBUHwiWFKDN2RUcX8DWCb5gj5E blmBlntUfRqVVFZIsU3vFFY3kVExSI0c8ve1hIKaZJevONOAz9bUGdJVjlqxLNo1Dpwj EfLg== X-Gm-Message-State: ALKqPwdVgSjjautq/FbZoLCfuJ8KSmcbcgF7wdktCh2Zf1pZcSE9lWLi ol7ZL+7UD2AfgqHAGRwHnX0Bfg== X-Google-Smtp-Source: AB8JxZoTIcHJ4DCmBm1G8o0D0IStWRzhJkmsuO8nZA0jabKpEuBc4jrhapGYMDQGm06/PDtTBEKCqQ== X-Received: by 2002:a62:7002:: with SMTP id l2-v6mr1794457pfc.40.1527060781590; Wed, 23 May 2018 00:33:01 -0700 (PDT) Received: from simonLocalRHEL7.cn.ibm.com ([112.73.0.86]) by smtp.gmail.com with ESMTPSA id a7-v6sm28650637pgc.68.2018.05.23.00.32.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 00:33:00 -0700 (PDT) From: wei.guo.simon@gmail.com To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v5 0/4] powerpc/64: memcmp() optimization Date: Wed, 23 May 2018 14:47:59 +0800 Message-Id: <1527058083-6998-1-git-send-email-wei.guo.simon@gmail.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Naveen N. Rao" , Simon Guo , Cyril Bur Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Simon Guo There is some room to optimize memcmp() in powerpc 64 bits version for following 2 cases: (1) Even src/dst addresses are not aligned with 8 bytes at the beginning, memcmp() can align them and go with .Llong comparision mode without fallback to .Lshort comparision mode do compare buffer byte by byte. (2) VMX instructions can be used to speed up for large size comparision, currently the threshold is set for 4K bytes. Notes the VMX instructions will lead to VMX regs save/load penalty. This patch set includes a patch to add a 32 bytes pre-checking to minimize the penalty. It did the similar with glibc commit dec4a7105e (powerpc: Improve memcmp performance for POWER8). Thanks Cyril Bur's information. This patch set also updates memcmp selftest case to make it compiled and incorporate large size comparison case. v4 -> v5: - Expand 32 bytes prechk to src/dst different offset case, and remove KSM specific label/comment. v3 -> v4: - Add 32 bytes pre-checking before using VMX instructions. v2 -> v3: - add optimization for src/dst with different offset against 8 bytes boundary. - renamed some label names. - reworked some comments from Cyril Bur, such as fill the pipeline, and use VMX when size == 4K. - fix a bug of enter/exit_vmx_ops pairness issue. And revised test case to test whether enter/exit_vmx_ops are paired. v1 -> v2: - update 8bytes unaligned bytes comparison method. - fix a VMX comparision bug. - enhanced the original memcmp() selftest. - add powerpc/64 to subject/commit message. Simon Guo (4): powerpc/64: Align bytes before fall back to .Lshort in powerpc64 memcmp() powerpc/64: enhance memcmp() with VMX instruction for long bytes comparision powerpc/64: add 32 bytes prechecking before using VMX optimization on memcmp() powerpc:selftest update memcmp_64 selftest for VMX implementation arch/powerpc/include/asm/asm-prototypes.h | 4 +- arch/powerpc/lib/copypage_power7.S | 4 +- arch/powerpc/lib/memcmp_64.S | 408 ++++++++++++++++++++- arch/powerpc/lib/memcpy_power7.S | 6 +- arch/powerpc/lib/vmx-helper.c | 4 +- .../selftests/powerpc/copyloops/asm/ppc_asm.h | 4 +- .../selftests/powerpc/stringloops/asm/ppc_asm.h | 22 ++ .../testing/selftests/powerpc/stringloops/memcmp.c | 98 +++-- 8 files changed, 510 insertions(+), 40 deletions(-)