From patchwork Fri May 25 04:07:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Guo X-Patchwork-Id: 920216 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40sXp20qHbz9s0q for ; Fri, 25 May 2018 14:09:46 +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="tZzks7YE"; 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 40sXp16BYWzF1d2 for ; Fri, 25 May 2018 14:09:45 +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="tZzks7YE"; 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:c01::243; helo=mail-pl0-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="tZzks7YE"; dkim-atps=neutral Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::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 40sXlp1XWBzF1RG for ; Fri, 25 May 2018 14:07:49 +1000 (AEST) Received: by mail-pl0-x243.google.com with SMTP id bi12-v6so2317349plb.12 for ; Thu, 24 May 2018 21:07:49 -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=uWKYP3MN2bpDXadkxcWUPuaPiGDpQtPAFZ/pf/De8CQ=; b=tZzks7YEjUTs2mBjUhgvzdZvMqMnxe56WoWRfSZ/tlgFhzkDQEqd40LefFFWja51q5 oV2TCnVpSbuYbVCdSXWDp9XFJmzz5ahg+8AOvUQapxZdsns+v5jcqiOyk/sI5Vr24zJo 9OXGsY/5LpKkS8C3sBcW4+QxeP6PnDBamAxZNK7GCTSYk0K6zb4iCOKW3LV+aeELMfx6 YTqaZpnhgsBtiNQsZRZYlK1LH2Dpeyb3r4TNmn7sksxXFz4kgQ+S94mJEWyZO0weGOFI 1aJl6D1IhuKjF6eLh5GFExIlXvwZzmZe/wtgRt3soaIsZ2sgGgqwgFGBDgepo4hgB4Zz NaOw== 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=uWKYP3MN2bpDXadkxcWUPuaPiGDpQtPAFZ/pf/De8CQ=; b=oW9hInQGflcrOH9hTbmwxyqpHwfyLDd+UUtedyYQl/opUm1mWQ1LJ56UGyGAr2Knwh pfBJbL9Kl3t3251RYWNS0V/G9S+S21GPux2+dmQmMjmfxfmUvhNyl9EBuT2K2PC3kc1d JaRE1HfIPtOYUaJce4/uODM9so+DLtUX7Vg4qdF5Thd/lCAb0+ggk3KMojf/fxZOMQpV vHWDvsy+D5fz3FxPdAXDLHMzXJeuqyzuGNpk2lEVgu+L9SEy7CpL2A06DxiDtkUljyL8 38ZvU07Oh2XVnUw9//cNonRjq2nw/Z8/85LkSPQPbNNJ4Fp1mR6ql0EiZWC6Ffsms1Lh yaXw== X-Gm-Message-State: ALKqPwfPpO8KBQD5NLJBfMZ2BMvbZv3H8aRILFQRQ1GQgKoQlG7XemId VB/cUuKNIyV2iU9/zFID3nO+Cg== X-Google-Smtp-Source: AB8JxZpgd9CGddIs/E4OOS3+Ka/br7aK979Y0OnRxqbbce7GM0VAesl2+3xXwijCySxlT9yoINdfFQ== X-Received: by 2002:a17:902:5502:: with SMTP id f2-v6mr889918pli.108.1527221267935; Thu, 24 May 2018 21:07:47 -0700 (PDT) Received: from simonLocalRHEL7.cn.ibm.com ([112.73.0.89]) by smtp.gmail.com with ESMTPSA id b13-v6sm30138808pgu.54.2018.05.24.21.07.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 21:07:46 -0700 (PDT) From: wei.guo.simon@gmail.com To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v6 0/4] powerpc/64: memcmp() optimization Date: Fri, 25 May 2018 12:07:32 +0800 Message-Id: <1527221256-17029-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. v5 -> v6: - correct some comments/commit messsage. - rename VMX_OPS_THRES to VMX_THRESH 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(-)