From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754520AbcFGIh7 (ORCPT ); Tue, 7 Jun 2016 04:37:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48193 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754304AbcFGIh4 (ORCPT ); Tue, 7 Jun 2016 04:37:56 -0400 Message-Id: <201606070837.u578YGqF033970@mx0a-001b2d01.pphosted.com> X-IBM-Helo: d06dlp03.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_equal memcmp optimization for s390 Date: Tue, 7 Jun 2016 10:37:40 +0200 X-Mailer: git-send-email 2.6.6 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16060708-0032-0000-0000-000001D3C8ED X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16060708-0033-0000-0000-00001B1D1633 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 Servus, while working on an improved TLB flush logic for s390 I noticed that for s390 cpumask_equal() alias bitmap_equal() can be improved for the special case "(nbits % BITS_PER_LONG) == 0". The memcmp function can be used in this case and we have an instruction for that .. Trouble is that the default memcmp implementation uses a byte loop while the __bitmap_equal function uses a loop over unsigned long. For x86 the __bitmap_equal function is faster than memcmp, using memcmp for the special case for all architectures is not correct. Right now the patches uses a '#ifdef CONFIG_S390' to guard the memcmp special case. I hesitate to put another CONFIG_S390 into common code, alternatively __HAVE_ARCH_MEMCMP could be used. There are 7 architectures with the define: arc, arm64, blackfin, frv, powerpc, s390 and sparc. Of those I guess only powerpc, s390 and sparc will have configs with (NR_CPUS > BITS_PER_LONG). For (NR_CPUS <= BITS_PER_LONG) the xor optimization is used. powerpc, s390 and sparc do have optimized memcmp code, the question is if it is faster then __bitmap_equal. Now, CONFIG_S390 or __HAVE_ARCH_MEMCMP ? blue skies, Martin