Return-Path: Received: from e23smtp07.au.ibm.com ([202.81.31.140]:57641 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933890AbbHKJmZ (ORCPT ); Tue, 11 Aug 2015 05:42:25 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 11 Aug 2015 19:42:23 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 834C22BB0059 for ; Tue, 11 Aug 2015 19:42:20 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t7B9gBpw66912420 for ; Tue, 11 Aug 2015 19:42:19 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t7B9fl9F028441 for ; Tue, 11 Aug 2015 19:41:48 +1000 From: Chandan Rajendra Subject: [PATCH] arch-ppc.h: Add ilog2 implementation for ppc64 Date: Tue, 11 Aug 2015 15:11:26 +0530 Message-Id: <1439286086-7822-1-git-send-email-chandan@linux.vnet.ibm.com> Sender: fio-owner@vger.kernel.org List-Id: fio@vger.kernel.org To: fio@vger.kernel.org Cc: Chandan Rajendra , david@gibson.dropbear.id.au, chandan@mykolab.com On a ppc64 machine, when fio is invoked with the following configuration file (generated by fstests' generic/300 test), it loops indefinitely. [global] directory=/mnt/btrfs-xfstest-scratch filesize=536870912 size=999G continue_on_error=write ignore_error=,ENOSPC error_dump=0 create_on_open=1 fallocate=none exitall=1 [direct_aio_raicer] ioengine=libaio iodepth=128*1 bs=128k direct=1 numjobs=4 rw=randwrite runtime=100*1 time_based filename=racer [falloc_raicer] ioengine=falloc runtime=100*1 iodepth=1 bssplit=128k/80:512k/10:32k/10 rw=randwrite numjobs=1 filename=racer [punch_hole_raicer] ioengine=falloc runtime=100*1 bs=4k time_based=10 rw=randtrim numjobs=2 filename=racer time_based [aio-dio-verifier] ioengine=libaio iodepth=128*1 numjobs=1 verify=crc32c-intel verify_fatal=1 verify_dump=1 verify_backlog=1024 verify_async=4 verifysort=1 direct=1 bs=4k rw=randwrite filename=aio-dio-verifier This is because arch_ffz() ends up invoking the 32-bit version of __ilog2() which always returns a bit number in the range 0 - 31. This can cause "overlap" variable in axmap_set_fn() to never becomes zero. To fix this the commit adds a 64-bit version of __ilog2() (obtained from the Linux kernel's arch/powerpc/include/asm/bitops.h). Signed-off-by: Chandan Rajendra --- arch/arch-ppc.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arch-ppc.h b/arch/arch-ppc.h index d4a080c..aed41f9 100644 --- a/arch/arch-ppc.h +++ b/arch/arch-ppc.h @@ -33,18 +33,24 @@ #define write_barrier() __asm__ __volatile__ ("sync" : : : "memory") +#ifdef __powerpc64__ +#define PPC_CNTLZL "cntlzd" +#else +#define PPC_CNTLZL "cntlzw" +#endif + static inline int __ilog2(unsigned long bitmask) { int lz; - asm ("cntlzw %0,%1" : "=r" (lz) : "r" (bitmask)); - return 31 - lz; + asm (PPC_CNTLZL " %0,%1" : "=r" (lz) : "r" (bitmask)); + return BITS_PER_LONG - 1 - lz; } static inline int arch_ffz(unsigned long bitmask) { if ((bitmask = ~bitmask) == 0) - return 32; + return BITS_PER_LONG; return __ilog2(bitmask & -bitmask); } -- 2.1.0