From patchwork Wed Oct 4 16:53:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13409080 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A57A3E7C4E3 for ; Wed, 4 Oct 2023 16:53:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3481F6B0292; Wed, 4 Oct 2023 12:53:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F7956B0296; Wed, 4 Oct 2023 12:53:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1711A6B0297; Wed, 4 Oct 2023 12:53:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id EF0F06B0292 for ; Wed, 4 Oct 2023 12:53:46 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BFFCE1A031B for ; Wed, 4 Oct 2023 16:53:46 +0000 (UTC) X-FDA: 81308375652.25.9EB6229 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 37ECF12001A for ; Wed, 4 Oct 2023 16:53:44 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RPsCKy9R; dmarc=none; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696438425; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GcBru3fPdpYKCu6uB4MY5f4K8PaG3ucCqPSqDGXRe9s=; b=fWZSrUwj0VcJMiKHHTeMWe6NrmCnxmBNMnAcWoyo4mSOtytItlqFJwS0crpOdog+dZ7fbb cFTF1ky23Vh5XhyzzTJ6rTZVQhdfRgI1B6GZMLAJku+AiiiE7KbxrwYqMTFzt4Tr830etT DCblQV6VIyZsXvYBEalAcAEOAaoPxCo= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RPsCKy9R; dmarc=none; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696438425; a=rsa-sha256; cv=none; b=70ypLtKB0UVcC/bBrISB6pALG2StnoSTOLocdsqOydTdC5Ci7v3la2RzwLsCbTrku49CGH Z3+NIDuye8oJfS9p7WgXp1MaT7YH6ybrr90cdfKzY3kw0JMJX72bCw4lBktmZLZFre6RIc zTe0LyUKw2v27mrhW46txwGjGKI5Pr4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=GcBru3fPdpYKCu6uB4MY5f4K8PaG3ucCqPSqDGXRe9s=; b=RPsCKy9Rm26TskJl3Eur107F7S 57OHLJxeUuwkSmlr5qVXZQNjmq1fs6H47cGDYcmjzJxyEwDsj8u0jKLys/oRopqDf28XCm639dRkF 9yBzlYSdR7vgpEP7jHoxcf6LR3/zR9PCM+Ttcw7pDWHC2Fb1C3BcOcK5DulZT8hp7ezhCo/yCky9S pkxMgSich07C8uTk28HlWqZ3lcIgGVe23a/iYvjX/OrOn/BuvAeYNMag8CYx0+Xxssf72G8/uGqXV AY5Kndoit3mw7LA3XgJfj3g5Ben6dO64o9z+tqXsl9Vk8Z6UXSNiqQBLfYajlHYtcokZxJlu28Tdu owaSdX3Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qo57f-004SFA-Pp; Wed, 04 Oct 2023 16:53:19 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, torvalds@linux-foundation.org, npiggin@gmail.com Subject: [PATCH v2 08/17] alpha: Implement xor_unlock_is_negative_byte Date: Wed, 4 Oct 2023 17:53:08 +0100 Message-Id: <20231004165317.1061855-9-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231004165317.1061855-1-willy@infradead.org> References: <20231004165317.1061855-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 37ECF12001A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: hy5jcq78z7ca6p88yciuxhn17ub8im7m X-HE-Tag: 1696438424-276292 X-HE-Meta: U2FsdGVkX18zHAzAJccHwIcSSrAYa02wIlFvLN6NY59Q32xf0lBT+ZYTQKgENBHGTaGs/C2jpH3RnyKboJn/IuQWLzo14u+c1UGjoNw33X+/62PLqnZa1UphrexjYz1mfj4aFU7hdzHyTDVUUHyjoUwSKRnupzuzwvEaow+cFl1GM2iw+DGpzH9sFHQBUxGuDcM9tBQfylyrcDNPwcmd1erZFjHT94FQaiUFRIkDaQOGZnUkmM1nzupLx2mV0W253PzPYtB2Og6AVM5VEoERlitIp4fxW3eAjz0xSc9SyWe1OewynZl0ggWPalSS5omrD5LHPtQaB55hRPKQ2fJ8RGrtwXRgDrT3uhqvft6NHSq/yYzjuOSppvEpFI4pgaIwCEMXxowyzPo5OTLNChKV85xR6iOID6gDDOsLM2sBIakv4skMVy+DX71jYkkmrwagFLY7AxGX9bO2P4PHdFGsYjx0oKop2sVV6Yo2ieseaKaBaTuGve9WgKSf/FE+IXY44v30lg90EkOVPHyaxsbSLy8oLGf0WQpwruivmj2OfNQnRGMjs7t+rkOjIfD1EUW+koMWzEVchIcdR4ka9LLDaifRJCwRg8CRPtbVXNrcBWPDgsx6o848XB2x4Z7KkQdRadIsqgSI86LvoIUlslPAztx9Gsgm7rGauWEWSj9/ttqfPCn3iAseqlqBVe1r48eRzq3jHUSZBNreyXPHhVE5mHPVkITqgmvTcRx8l9w8+nM4Wo6xtNibVE36M7ndeoNSSLCHXxLKKYSdD3TjL0sTBPkRUugeVRV7J1PV4FS6G/h/F8Df2IjKYZj/w1Tbc2l8jj1oJQZbQBkrogpZx1bYoWn/7cWHdVj26oRF8ogKorasLxxlRVQv3Y5RQtwsltmgmcGXX8j6+mZ837svW/A40l+p6JIAN6nW3NUnRL4633zMZv2GCO0bxSMNct7GeVrilqmzclFaS4QTFiApjOe N/UCwrsM iEH4C5dnyg7Cg1itZ7uRyBoT3vOy/YoTJ0GSNpJwYX9ROznWW7A7eBwXBg/4F8eYxBqHLOz0IySJkulZonVDjpIO3WFG4PMbHNN0Zq3E5GjcvEdYmZbs2bkWh6QU33Mza9MIDOBWL7cagCaUMXPkkm7w0N9Y8Tic5xKjFaBbflrjNxDzXlvSS1mUAoJbHXJcebrJ6fAK/bLJKzenn03+Qs4fszrS9+sOBiAIR X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Inspired by the alpha clear_bit() and arch_atomic_add_return(), this will surely be more efficient than the generic one defined in filemap.c. Signed-off-by: Matthew Wilcox (Oracle) --- arch/alpha/include/asm/bitops.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/alpha/include/asm/bitops.h b/arch/alpha/include/asm/bitops.h index bafb1c1f0fdc..b50ad6b83e85 100644 --- a/arch/alpha/include/asm/bitops.h +++ b/arch/alpha/include/asm/bitops.h @@ -286,6 +286,27 @@ arch___test_and_change_bit(unsigned long nr, volatile unsigned long *addr) #define arch_test_bit generic_test_bit #define arch_test_bit_acquire generic_test_bit_acquire +static inline bool xor_unlock_is_negative_byte(unsigned long mask, + volatile unsigned long *p) +{ + unsigned long temp, old; + + __asm__ __volatile__( + "1: ldl_l %0,%4\n" + " mov %0,%2\n" + " xor %0,%3,%0\n" + " stl_c %0,%1\n" + " beq %0,2f\n" + ".subsection 2\n" + "2: br 1b\n" + ".previous" + :"=&r" (temp), "=m" (*p), "=&r" (old) + :"Ir" (mask), "m" (*p)); + + return (old & BIT(7)) != 0; +} +#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte + /* * ffz = Find First Zero in word. Undefined if no zero exists, * so code should check against ~0UL first..