From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754617AbcFGIli (ORCPT ); Tue, 7 Jun 2016 04:41:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37085 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754326AbcFGIh6 (ORCPT ); Tue, 7 Jun 2016 04:37:58 -0400 Message-Id: <201606070837.u578YJKt047781@mx0a-001b2d01.pphosted.com> X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: schwidefsky@de.ibm.com X-IBM-RcptTo: linux-arch@vger.kernel.org;linux-kernel@vger.kernel.org From: Martin Schwidefsky To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Herrenschmidt , "David S. Miller" Cc: Martin Schwidefsky Subject: [PATCH] bitmap: bitmap_equal memcmp optimization Date: Tue, 7 Jun 2016 10:37:41 +0200 X-Mailer: git-send-email 2.6.6 In-Reply-To: <1465288661-3273-1-git-send-email-schwidefsky@de.ibm.com> References: <1465288661-3273-1-git-send-email-schwidefsky@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16060708-0032-0000-0000-000001D3C8EA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16060708-0033-0000-0000-00001B1D162E X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-07_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=8 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606070103 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The bitmap_equal function has optimized code for small bitmaps with less than BITS_PER_LONG bits. For larger bitmaps the out-of-line function __bitmap_equal is called. For a constant number of bits divisible by BITS_PER_LONG the memcmp function can be used. For s390 gcc knows how to optimize this function, memcmp calls with up to 256 bytes / 2048 bits are translated into a single instruction. Reviewed-by: David Hildenbrand Signed-off-by: Martin Schwidefsky --- include/linux/bitmap.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index e9b0b9a..27bfc0b 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -267,6 +267,10 @@ static inline int bitmap_equal(const unsigned long *src1, { if (small_const_nbits(nbits)) return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits)); +#ifdef CONFIG_S390 + else if (__builtin_constant_p(nbits) && (nbits % BITS_PER_LONG) == 0) + return !memcmp(src1, src2, nbits / 8); +#endif else return __bitmap_equal(src1, src2, nbits); } -- 2.6.6