From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BFF6AECAAA1 for ; Fri, 28 Oct 2022 19:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5lah204MhaoZc75G1y2dhNH2SRTErsyoaSRFf6fo5iE=; b=dLHKoWXjWD3tPW GnGchfwvnDoHyA+f7pNIbU6Bd7Ek8PDKgaJBz3+np7LEd0Roao84fgjiWGbTwQQB0FBChWjD67liC eEGheN53LJdCKW5yGGmMyKWeF4WYNS5y6X6v0K683+Jj+ILddqh+R9hft7UFTKHXXRrXYXpoMS4VE kOS9OmlrO0abOi4ys6eHtV6Yj0LKKzjtN7egGe+9oO2/DHvn+k3NUDKXm6JJWdQf8oKbYyrcWCNwK RsQmxEAGuO+hvku9tzvXkZ/2wMHvzTMvnKPHdFUSEGWCShviJpDWKxOLU9MJ3jS7TVx1L2dtxuyIG nn/ufBfCjU+VAD5L68dQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooVJf-001zMR-8m; Fri, 28 Oct 2022 19:46:55 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooVJc-001zJt-Ci for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 19:46:53 +0000 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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_124652_457874_9DA1F439 X-CRM114-Status: GOOD ( 14.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel