From patchwork Wed Oct 4 16:53:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13409064 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 24530E7C4E8 for ; Wed, 4 Oct 2023 16:53:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98AA56B0266; Wed, 4 Oct 2023 12:53:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 878D26B026E; Wed, 4 Oct 2023 12:53:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 62AAD6B026F; Wed, 4 Oct 2023 12:53:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 504A96B0266 for ; Wed, 4 Oct 2023 12:53:24 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 13DA61403AF for ; Wed, 4 Oct 2023 16:53:24 +0000 (UTC) X-FDA: 81308374728.21.6702432 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 040F4180019 for ; Wed, 4 Oct 2023 16:53:21 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NWC6d6ZF; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696438402; a=rsa-sha256; cv=none; b=ysnceRZ9X+OJzSSN8lY34A6l5ZCKbaTIjbkB4rM2kOzyGxC5wRpYTbaTdhTwCqvmY2v90l xCkOwaCNenuxDOB6IrtFNpwrt7FpfXzZwYKCo85srR7bKYFkW/hLluZEEyv3XsLchah+KN J0B9Gtpk1IITRomhSTkGLbB8bxwigW4= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NWC6d6ZF; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696438402; 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=bfs2p6og8MVmu/PmsnwWj8Grt12H9inYLMhPvOjgtD4=; b=n+pD70rhOh90ylLJjRBzOdG9mwQQXv3WlZSJ0Z9RodDBX3Jk2j7CWSNbgxgU0NUXRq+759 coopkp6AvhDPjmt9iZiAmGNDuVLDZPrI1PVaa+IHmcHFxo/iDXiyXyJ13RSVb/wYYg3C5y zvjV9WeMaVrIfGPBDFkfV4qcAY43SPo= 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=bfs2p6og8MVmu/PmsnwWj8Grt12H9inYLMhPvOjgtD4=; b=NWC6d6ZFQxlxn/oWJ2tJnU0gwB ZelMR2zlgkLzaavxoF29vyK9rUKk3wZoVjQYF4K0JVoHtYF3lYdM3bogFOO8lFAEDNgqsWBU/VXZr YHo3HmIrljWo2RkuVx1+vSIVD0DPaQJalBikdceY0434SmUBzRY1jyCXk/mJwjly9XRiLKBwBwU0m 2HpWLNh91z6H8q4wUtSN7qp3N6J7evJn15lOl5L3vi8PtH4ySsZtI3e7CYoaeQaMTanTOJmyLMy2C 6wLxIkOasNlqbdxCUl5F6HQe+SYdShEeFYIl91MG5vji2Y56KV2H2hSVVyLjqcZCmQMVLsqOrDh6m rKkojOcg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qo57f-004SFN-Sx; 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 09/17] m68k: Implement xor_unlock_is_negative_byte Date: Wed, 4 Oct 2023 17:53:09 +0100 Message-Id: <20231004165317.1061855-10-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-Server: rspam08 X-Rspamd-Queue-Id: 040F4180019 X-Stat-Signature: sdwz7t9iaz5hridn89wgqa9j8edx33fu X-Rspam-User: X-HE-Tag: 1696438401-626384 X-HE-Meta: U2FsdGVkX18zrYirk6WYdwM0tyrHDyi51d8Cb3c3mErxOXpKfHUaiRSaJ1t4NrjmbbrEK1NTiIAduf8ZEhxP6w4vIm5I/E9CxdAryhlF5sNfkFT4HQrUpUhF7zBEvjGZtxjDY1yQSctMnpgGEgnJdVj5PtIzxO/BB8Ge/UZoxm53Bc9C4WXbCxZZVk5sHOubunfP8l9bDXNfafIn4wL4NvXiPUe5Ujml+dkYxxLYoc5P/tDMTZNSbyUe+lCXQNUBdIKfGpRjg2Y89lXtVsvVL1RDVjopjy5AmPe5PavjGnR8bhOVWSh4313Ek55D09Xh+ACpEaYxcbl0dnviyEkXLEVKAI2/wr0/NecpcCA5neEVvRauDuSAum6iBOOxris5gGyzQ8Ws8Npif0ww5DYgpQkCRfXBUbv6CoQXLCpBHNSkMu20iKv+GQZV0QRvIIw92IJ8gQnwZY5XbsKNzia8AIGCZx67sjH2Gm9dLWLhBjdOnqWVjPwoF0LzKMm5rkvpILm0eAaYQB0aBLlKcnZcnDiwTyUNLQNi3juBeNCS02B4yIvoINTgm4Qic/mk5ZqJiJhaKrKAXTmNYJOWyad2uUXPBL5JI3KXIsHCOiBalJOUgD0BEekrYVlyJ5GlynKbZxTMTR/HZn9OPpCyt+xckhtgsVozqWRjtczTkTuncW/eKp9yyAbEZS8jLiaz11AJaHWHf//WSqWT3+a8lrcxOZ7vnGeyNLCKa8xrmtcxKJGTP9X2bIHjpxiDUhFOGRaObnHqMSscGEVkHWEH0RT+GTj/Lo4y8zqE/JcIe/Osx7s7014g7vNiuFtIlAycc8ohB2+Eqg4A3v+sXjruI2D13M/0sfyl+qmQ4B+FubkHLZwrZvDJMeR+GdMrIwMCAwjgIu62HhFGGOg7n+5wJhMuvsg/77nLjAQHnn24BBRUe6aaEXBYoSMM4r87sDramhO83hgYi3cD9MFrd3Qrj6N SRYIbM5r oJd3ApruOxW/nGsDaFLHzaOzVb37dAUKShbfJOfZ1mbNt3vE5xI+TFtm5h5EQKNTWRUMd6ZIJqNRO3CCDjzTW9MMEfXl+OKBfD/2laX0dwvsrMT1pocZwncG6YFyp1dyoOWzoijvpUdTV8JfZDYMiiZDywcykGEvD81yuvhjc/CipKQmk38pJsESI5M6gTMKK94zYpw6nYGD51YGMptuyF0SOnLWTYahlEC5N 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: Using EOR to clear the guaranteed-to-be-set lock bit will test the negative flag just like the x86 implementation. This should be more efficient than the generic implementation in filemap.c. It would be better if m68k had __GCC_ASM_FLAG_OUTPUTS__. Coldfire doesn't have a byte-sized EOR, so we test bit 7 after the EOR, which is a second memory access, but it's slightly better than the current C code. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Greg Ungerer Acked-by: Geert Uytterhoeven --- arch/m68k/include/asm/bitops.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/m68k/include/asm/bitops.h b/arch/m68k/include/asm/bitops.h index e984af71df6b..80ee36095905 100644 --- a/arch/m68k/include/asm/bitops.h +++ b/arch/m68k/include/asm/bitops.h @@ -319,6 +319,28 @@ arch___test_and_change_bit(unsigned long nr, volatile unsigned long *addr) return test_and_change_bit(nr, addr); } +static inline bool xor_unlock_is_negative_byte(unsigned long mask, + volatile unsigned long *p) +{ +#ifdef CONFIG_COLDFIRE + __asm__ __volatile__ ("eorl %1, %0" + : "+m" (*p) + : "d" (mask) + : "memory"); + return *p & (1 << 7); +#else + char result; + char *cp = (char *)p + 3; /* m68k is big-endian */ + + __asm__ __volatile__ ("eor.b %1, %2; smi %0" + : "=d" (result) + : "di" (mask), "o" (*cp) + : "memory"); + return result; +#endif +} +#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte + /* * The true 68020 and more advanced processors support the "bfffo" * instruction for finding bits. ColdFire and simple 68000 parts