Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2951633rwi; Fri, 28 Oct 2022 13:36:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6bKFuTx6IoJdi/S97nMpL1BL8Vghh4xTlQkuu47UxFH/8fO0er3TXSnVU1H0qZI4/8qPp+ X-Received: by 2002:a17:906:9c83:b0:779:c14c:55e4 with SMTP id fj3-20020a1709069c8300b00779c14c55e4mr982299ejc.619.1666989387284; Fri, 28 Oct 2022 13:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666989387; cv=none; d=google.com; s=arc-20160816; b=uaPh7wwRAeAvX/GM5VS+GZckfLQBFXR96/96f3R7ayk28lFSdmf/iRvXodt0Crjuw1 syP+p0ttF4g8KtYnFE0zgqBuEuvm9Qc12cAmY81+gKmzSBNLDfT3TqvLWQUIUR81XzAi bbYwjnJZXnhH0r2qU3Sr80Y6mCjPtXgnHphyBuakwTLhKWXnEpz2uCJm6hxudwGNnzWF ZWoGilyKPvoDYIgWzVYCIVZX/gElpOHiQxZya5YrAA96S5Jr6VZgsEIn2TPwe+cwVkEA pm0Ue/OeuPszlZVT8nesP8tJ5MK4uzYf90LK0qCBM3EaqCHut/YYku4VMAKTdlk0hTLW KieA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=f7UPO9GglDNa6WGQuH0EZ+JACzYc8vMJ42PwWrpInB8=; b=htK+CiSySLVA2+g728Qo7FwauDfH8RqDlRayFetzWykxMzW7zenf6lTgkMuFNAuw5m cxGyJ9Fxsc7ADC0x1PsDb2fEusF5CpBl9fR+PWGyLnUdLISV4d5f9DKokeWDjdCYAimZ 8XBS3/xzMhq7fjpohyWBWW5MHIgRrkXlTbCzyC4AYgrHRqEZTgwthrG00wwfK67634lH 7ZHGBoaz/X/YeFXeSpwUXOqnXBTTseb2/IOXxnUuHBhvQvmNEzyjo54PxYXhxP5qO5/S cAfmKbokw7Rid1C+2oRClqRa4rUSUeX5UQtJ07efbXA1I3ydRISk10o1m4xRdLmiCmF1 mhug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=Xs66s8Bc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs13-20020a1709073e8d00b00779e6c93108si4355145ejc.598.2022.10.28.13.35.59; Fri, 28 Oct 2022 13:36:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=Xs66s8Bc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbiJ1Tq4 (ORCPT + 99 others); Fri, 28 Oct 2022 15:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbiJ1Tqy (ORCPT ); Fri, 28 Oct 2022 15:46:54 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E9346619 for ; Fri, 28 Oct 2022 12:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=f7UPO9GglDNa6WGQuH0EZ+JACzYc8vMJ42PwWrpInB8=; b=Xs66s8BcaErNF5KJA7QVqJlVle 0w9H2YhZR7p9mVEuBucPzDlLrVI2aRUr8eZNE6yTDR6iJ5Qg3CJBc1ch0s+jCXF44JQphqp8yP81K d8sBUdVeR4RR6tSM/UUUJl8ZtgcUZ0YESU8oMxIgcUu4WMEsvHBqor4l6N0LlzGhUbWi0aKytZsjD pDKC8xDvX6vRs9VtYMcBMrnv7cNY0mWTTPY14tDC76cSNDAdiUioMSnxMjy1GTAT5FZHJYLZ1UWbA m/PdfKL7MF98FMjWydP0oSbJc7Knjmi5k+g4FSvTxdAgeUKdrCs/Ybvphfnv0S9oIfRirsTN6noSd T4r1j3Bg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:35018) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ooVJZ-0000LY-O4; Fri, 28 Oct 2022 20:46:49 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1ooVJY-0002q9-VX; Fri, 28 Oct 2022 20:46:48 +0100 Date: Fri, 28 Oct 2022 20:46:48 +0100 From: "Russell King (Oracle)" To: Linus Torvalds Cc: Yury Norov , Catalin Marinas , Mark Rutland , Will Deacon , Linux Kernel Mailing List , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 1/5] ARM: findbit: document ARMv5 bit offset calculation Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Russell King (Oracle) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 28, 2022 at 12:01:00PM -0700, Linus Torvalds wrote: > Hmm. Interestingly, your _find_first_zero_bit_le() (which > find_next_bit ends up using except for the first byte) ends up doing > an optimization that is technically not valid. > > In particular, the *generic* code does > > sz = min(idx * BITS_PER_LONG + __ffs(MUNGE(val)), sz); > > for the final result. > > In contrast, the arm code doesn't do the "min()" at all, and if there > are bits after the bitmap (in a partial byte), it will just return > those bits. You've missed how the min() is coded. Specifically, that's handled by: cc: e1510000 cmp r1, r0 d0: 31a00001 movcc r0, r1 which clamps the returned index to the size of the array (held in r1). So everything is in fact fine - and I think your analysis is incorrect. Please could you take another look and evaluate whether you think the arm assembly is incorrect. I kind'a stopped reading here on the assumption that the remainder of your email was based on this misinterpretation of the code. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!