Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5046054rdb; Sat, 16 Sep 2023 00:09:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG//96KRKe6Ysciapqp2ACvGiz5N2oPFT3v83/QLPrb7TZ5E9/1SqcfjQM4FFqAoSddy/T8 X-Received: by 2002:a05:6e02:13e5:b0:34f:6e7a:52b2 with SMTP id w5-20020a056e0213e500b0034f6e7a52b2mr4202282ilj.16.1694848148051; Sat, 16 Sep 2023 00:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694848148; cv=none; d=google.com; s=arc-20160816; b=xJt+U/QbAO85zOnw/e9pnKp2eNtyDieWUaP8kQfNj2oUzz6zHQUuM/e4U6s4ncnmbK 97gI/pZbJmX2dhUvX3G1mlot7JgLGFfSshOSfgx6ssXxgb7DDq+t5FGWB6Hzn50RtYQ1 B6xUn9mOOp9R8XDCh0L/QggLBvJ/bKSeZF8Gcf9nSHbYzvZy2pCq8PcvsK7i2q+qMw7t vI3oAXQrlR7NsmjTeVkf05dJRI/QxB1YVZWj1b2acTHrILYk9iFo+/X5jUKturNIG3ZY 2tf1yPUKmsv3K3wZXMqnycPuPcnmUXRpnREMVf2ILVaf+GCOWutKmEA6xjTEamzimjQT QuXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aiOK8Ht5TYsSZN2/F06YkBbUJBHTCETngx448aYGRJo=; fh=Exu8p2J0bt/MoYkEByA/Woj5EWTdUoRsvJYmK88z1hY=; b=U77o9zSv2a+ZtKz3A0tlVKT9y6zZwlz9+ve62eRQI8vF0/+wxo0+I2lhrqL/nAFAIW LAxQ57oRkF18IxXDzDr9faptLYl8z8M3zt+PIfB5siAVSYFKnSQfVqXE+Ic7wchMcGun osqMLLtNpojMpBOWQw8xx3zv/aQp/j9XriLRRBdlTK9C6IQtNE3yTqTA6tQwPOTtjaEK 3Sw99FI+4DJKddlaHAlalgp1MXRktte4jO1JQkY+5nOzSVP5wT9ap4NfJZiDU8gQF8X8 oKpCWNLd+AP0aKbBUYs56z7JfbcxZlqH5dgi5ojFBzIAjz8NegJviW9MGRHcdR6SD2kY W1EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=lZMQHaT7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id x15-20020a63170f000000b0057745b2d018si4311767pgl.390.2023.09.16.00.09.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 00:09:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=lZMQHaT7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 28A288024B19; Fri, 15 Sep 2023 11:38:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236595AbjIOShv (ORCPT + 99 others); Fri, 15 Sep 2023 14:37:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236584AbjIOShX (ORCPT ); Fri, 15 Sep 2023 14:37:23 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 989CE115; Fri, 15 Sep 2023 11:37:16 -0700 (PDT) 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=aiOK8Ht5TYsSZN2/F06YkBbUJBHTCETngx448aYGRJo=; b=lZMQHaT7hrHggJzlXzltWr+GSJ qxn67jKJoABNtVciXoBauvhbi6w3aXeLZ0ycZ3yb9R6L4faLx91CivKqEPdiry2EIJjszDL8doCjW 1UfpDGS7b8//AUC/Wz3x0Xe2ldF0BmllLcpXTk3b8tv9FJoO4eqRjV5sm4mQKyejpk/kFrrJX8Lb8 a0wwwl6e0Wh4jKeS43OdT65t/QTdLpmFX8WmtjN8ta2O6GwcTFPfaiyWj/f04D58AtSZ4/Xsvjs8/ jK4zI1ygqWAio3mfxoew53STS7AXfgxZBwVMSeFUh39RWCIxD7DFd5zw9+ZLhR/jlNdpWm1gvozav dtKXH3oA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qhDgk-00BMIw-0T; Fri, 15 Sep 2023 18:37:10 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, torvalds@linux-foundation.org, Nicholas Piggin Subject: [PATCH 12/17] riscv: Implement xor_unlock_is_negative_byte Date: Fri, 15 Sep 2023 19:37:02 +0100 Message-Id: <20230915183707.2707298-13-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230915183707.2707298-1-willy@infradead.org> References: <20230915183707.2707298-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 11:38:20 -0700 (PDT) Inspired by the riscv clear_bit_unlock(), this will surely be more efficient than the generic one defined in filemap.c. Signed-off-by: Matthew Wilcox (Oracle) --- arch/riscv/include/asm/bitops.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/riscv/include/asm/bitops.h b/arch/riscv/include/asm/bitops.h index 3540b690944b..15e3044298a2 100644 --- a/arch/riscv/include/asm/bitops.h +++ b/arch/riscv/include/asm/bitops.h @@ -191,6 +191,19 @@ static inline void __clear_bit_unlock( clear_bit_unlock(nr, addr); } +static inline bool xor_unlock_is_negative_byte(unsigned long mask, + volatile unsigned long *addr) +{ + unsigned long res; + __asm__ __volatile__ ( + __AMO(xor) ".rl %0, %2, %1" + : "=r" (res), "+A" (*addr) + : "r" (__NOP(mask)) + : "memory"); + return (res & BIT(7)) != 0; +} +#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte + #undef __test_and_op_bit #undef __op_bit #undef __NOP -- 2.40.1