From patchwork Wed Oct 4 16:53:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13409072 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 7FEACE7C4E5 for ; Wed, 4 Oct 2023 16:53:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 322A76B0276; Wed, 4 Oct 2023 12:53:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 283506B0279; Wed, 4 Oct 2023 12:53:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D5106B027A; Wed, 4 Oct 2023 12:53:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F1A2E6B0276 for ; Wed, 4 Oct 2023 12:53:28 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C44161CA3C9 for ; Wed, 4 Oct 2023 16:53:28 +0000 (UTC) X-FDA: 81308374896.09.2232C9B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id 0D2FB1C0011 for ; Wed, 4 Oct 2023 16:53:26 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=jIVsI8tP; spf=none (imf21.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=1696438407; 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=i/THylbIgEiK5ujFChvbIlJFdxL/ilDxv/jfyb9enPw=; b=O/AABAxuJe3Am1nPybaiVdEbN2NPOamxBa8txZnV86ZqDFw/8BEdc+V14ntA1WdsPFCtKT nVU/p28nC4xiIIS6N+1Mct5/87NI6q56gV/17hJVkyXeXmTomfjgN9+pUq3M8rCGT7dwjt BS241S3Y+955l24gEiXeI4D3+kL25dE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696438407; a=rsa-sha256; cv=none; b=HZaf3yRJY74JacGgEbVdyU9tXtLpH2LalPFI/Wc/ySlmUumNyrcE7KYzAwBeP3kuwXS8oP vgnPvkotTCI+icY5fgI7XL5HdrqPu60EFCXD749oZHGrKls9znqLuI4T3sFYRuVy8+cNmX UWbVPmQHmpnFrnqA7Ok+mYaFCUB7+wM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=jIVsI8tP; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=i/THylbIgEiK5ujFChvbIlJFdxL/ilDxv/jfyb9enPw=; b=jIVsI8tPAzH0SuNZpA70UkD5li 2ws2ktmfhTETzp44zx30Rj9cF7rmj9iSam52cmLtD0fu7LWyO6J9MfhW/ItU/0mYyQpkG/GaFTOiS kB32jO5aGAKCM3OKMlg5DQTcWcRHrCko9YH2S0INbvfuU4UuxB4qhmD3ltPfXcRUZqoMw38oHnZl2 2wDQWLhiLgfIjTK50jjihtxELCyWi0fWlirRWojikdn1mVv4Qt9HX9LaSE5beZZ4O68691U7CLC4l d3rZmrFJKUFhTUi/qSlmzAYNR4Hwxiwqzn8aAmQjfq8wm1VaHjq1rWwaIMLyICz0IcHYiZvN3jNze 9SjzPzXg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qo57g-004SFx-KW; Wed, 04 Oct 2023 16:53:20 +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 14/17] mm: Delete checks for xor_unlock_is_negative_byte() Date: Wed, 4 Oct 2023 17:53:14 +0100 Message-Id: <20231004165317.1061855-15-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: 0D2FB1C0011 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: q9ik98c549zkdtinkzobrqwg61ummne1 X-HE-Tag: 1696438406-8321 X-HE-Meta: U2FsdGVkX1/Q2P5w7K1TOHdpyMTQ9uKWi3MQhIrxc+8nseD6vagEtCCxJZKv39tw54Qr1ldrMo6sXQQMSu+YUEhGDCv8yEiC8B01EiojG6cqJ4mGGWTb97wuzfQxXA8GyIm/WmmVbJsgrZ7p55NcIV1rCp8BQ6jl3VhXZULHRsw1+F34y4ieVL3IWIYDJVWTYVNBRvsAdI+v9uq3BPq5Zq6EBEBkTYYs+vpo2y7YShNOhbe8BMKuR7KBoGrxGmmxzfvRDlEbH7PJHupLmijJh16UZUXoJzOvm6kPgRjf5RgMJN+p8zhSi1KUA0ZFybNj52Aclzk6dlHycdnVLePmhvPmyKGl1JSKZlYt1kS2DqYiUsZPhTKIqcCRl/wjstLAt0RZa3TDt9IyeSZvYIetujYlEL+QmgpbSX+6+SyMk0x4lnTuY0Wfu9dhteBiVzRaEhLfTgQyaUeq+n7xzcqNl6y7Ge3H3amk8Epy/0L8IIdMAAUq83L05lArw+Di3vrBIwfVQA9+SMwQeGMs6OIp6/pdlHLeLYTWheJpmWRMcI/OFbLiGQUiNkCjh77YSUcwIfczPoRZOnby+s5iIWkpomlhP5pUUW4XoGYs0w9GZaOiRrgZCHS4eaD9Ubz8FkVM0iXy7EZ4eUdZ8zRcYoKBVBHOSa81kPff3gIWY6g+JkAO6zbGFiWYpkhfcqcnQx/uHnIQbgHhIVzeL7bTgoa7TKlLE4G0qd+E8tvjBTmYHtq8C74X03mtPRkfWodhFjewDQgtSJqfC/I8aAO9zAw83Pq/Xi3m0c1PhUMTFenZWT08cipDDyzioiBFtbZmQahS8fH+qSeyLdEjKCbjtdPGxDoz3TDX5KFiswhcO9NtysfWWV8GXNeQkA0Lb/jFJZP775sXUEXAx3Rhu+Lx822yJOX2kBoj0ZTw8mTqBmYLeC050K0FnvKkFuMWB6xRWQanJt0BUTCiFC+TN5nmjQq seagG4zH EJFUKHnYiWMyqPehhdtc5Zv4L/ecu9hKzJ12zlv6PFXNXI9QqxSyFj/Uppt2z6yW+yochtW2naAxh6VeXHUailQuApPqxC8EwOhlNx2C2OAwLFtgvIuilDIylue/xKb/+N6TmF0uH9Q0Ca5iOyeL/X9fAG80j6FJTYGu7i87TLflKIVnW1fXM7RcVPYr37jmzJyZ5iPXXJkdMFTPuXKlf5dtIwEJ6n5LJUwjo 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: Architectures which don't define their own use the one in asm-generic/bitops/lock.h. Get rid of all the ifdefs around "maybe we don't have it". Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Geert Uytterhoeven --- arch/alpha/include/asm/bitops.h | 1 - arch/m68k/include/asm/bitops.h | 1 - arch/mips/include/asm/bitops.h | 1 - arch/riscv/include/asm/bitops.h | 1 - .../asm-generic/bitops/instrumented-lock.h | 5 ---- include/asm-generic/bitops/lock.h | 1 - kernel/kcsan/kcsan_test.c | 3 -- kernel/kcsan/selftest.c | 3 -- mm/filemap.c | 30 +------------------ mm/kasan/kasan_test.c | 3 -- 10 files changed, 1 insertion(+), 48 deletions(-) diff --git a/arch/alpha/include/asm/bitops.h b/arch/alpha/include/asm/bitops.h index b50ad6b83e85..3e33621922c3 100644 --- a/arch/alpha/include/asm/bitops.h +++ b/arch/alpha/include/asm/bitops.h @@ -305,7 +305,6 @@ static inline bool xor_unlock_is_negative_byte(unsigned long mask, 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, diff --git a/arch/m68k/include/asm/bitops.h b/arch/m68k/include/asm/bitops.h index 80ee36095905..14c64a6f1217 100644 --- a/arch/m68k/include/asm/bitops.h +++ b/arch/m68k/include/asm/bitops.h @@ -339,7 +339,6 @@ static inline bool xor_unlock_is_negative_byte(unsigned long mask, return result; #endif } -#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte /* * The true 68020 and more advanced processors support the "bfffo" diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h index d98a05c478f4..89f73d1a4ea4 100644 --- a/arch/mips/include/asm/bitops.h +++ b/arch/mips/include/asm/bitops.h @@ -301,7 +301,6 @@ static inline bool xor_unlock_is_negative_byte(unsigned long mask, return res; } -#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte #undef __bit_op #undef __test_bit_op diff --git a/arch/riscv/include/asm/bitops.h b/arch/riscv/include/asm/bitops.h index 15e3044298a2..65f6eee4ab8d 100644 --- a/arch/riscv/include/asm/bitops.h +++ b/arch/riscv/include/asm/bitops.h @@ -202,7 +202,6 @@ static inline bool xor_unlock_is_negative_byte(unsigned long 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 diff --git a/include/asm-generic/bitops/instrumented-lock.h b/include/asm-generic/bitops/instrumented-lock.h index e8ea3aeda9a9..542d3727ee4e 100644 --- a/include/asm-generic/bitops/instrumented-lock.h +++ b/include/asm-generic/bitops/instrumented-lock.h @@ -58,7 +58,6 @@ static inline bool test_and_set_bit_lock(long nr, volatile unsigned long *addr) return arch_test_and_set_bit_lock(nr, addr); } -#if defined(arch_xor_unlock_is_negative_byte) /** * xor_unlock_is_negative_byte - XOR a single byte in memory and test if * it is negative, for unlock. @@ -80,8 +79,4 @@ static inline bool xor_unlock_is_negative_byte(unsigned long mask, instrument_atomic_write(addr, sizeof(long)); return arch_xor_unlock_is_negative_byte(mask, addr); } -/* Let everybody know we have it. */ -#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte -#endif - #endif /* _ASM_GENERIC_BITOPS_INSTRUMENTED_LOCK_H */ diff --git a/include/asm-generic/bitops/lock.h b/include/asm-generic/bitops/lock.h index 6a638e89d130..14d4ec8c5152 100644 --- a/include/asm-generic/bitops/lock.h +++ b/include/asm-generic/bitops/lock.h @@ -75,7 +75,6 @@ static inline bool arch_xor_unlock_is_negative_byte(unsigned long mask, old = raw_atomic_long_fetch_xor_release(mask, (atomic_long_t *)p); return !!(old & BIT(7)); } -#define arch_xor_unlock_is_negative_byte arch_xor_unlock_is_negative_byte #endif #include diff --git a/kernel/kcsan/kcsan_test.c b/kernel/kcsan/kcsan_test.c index 1333d23ac4ef..015586217875 100644 --- a/kernel/kcsan/kcsan_test.c +++ b/kernel/kcsan/kcsan_test.c @@ -699,12 +699,9 @@ static void test_barrier_nothreads(struct kunit *test) KCSAN_EXPECT_RW_BARRIER(spin_unlock(&test_spinlock), true); KCSAN_EXPECT_RW_BARRIER(mutex_lock(&test_mutex), false); KCSAN_EXPECT_RW_BARRIER(mutex_unlock(&test_mutex), true); - -#ifdef xor_unlock_is_negative_byte KCSAN_EXPECT_READ_BARRIER(xor_unlock_is_negative_byte(1, &test_var), true); KCSAN_EXPECT_WRITE_BARRIER(xor_unlock_is_negative_byte(1, &test_var), true); KCSAN_EXPECT_RW_BARRIER(xor_unlock_is_negative_byte(1, &test_var), true); -#endif kcsan_nestable_atomic_end(); } diff --git a/kernel/kcsan/selftest.c b/kernel/kcsan/selftest.c index 619be7417420..84a1200271af 100644 --- a/kernel/kcsan/selftest.c +++ b/kernel/kcsan/selftest.c @@ -227,12 +227,9 @@ static bool __init test_barrier(void) KCSAN_CHECK_RW_BARRIER(arch_spin_unlock(&arch_spinlock)); spin_lock(&test_spinlock); KCSAN_CHECK_RW_BARRIER(spin_unlock(&test_spinlock)); - -#ifdef xor_unlock_is_negative_byte KCSAN_CHECK_RW_BARRIER(xor_unlock_is_negative_byte(1, &test_var)); KCSAN_CHECK_READ_BARRIER(xor_unlock_is_negative_byte(1, &test_var)); KCSAN_CHECK_WRITE_BARRIER(xor_unlock_is_negative_byte(1, &test_var)); -#endif kcsan_nestable_atomic_end(); return ret; diff --git a/mm/filemap.c b/mm/filemap.c index 7da465616317..ab8f798eb0af 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1484,34 +1484,6 @@ void folio_add_wait_queue(struct folio *folio, wait_queue_entry_t *waiter) } EXPORT_SYMBOL_GPL(folio_add_wait_queue); -#ifdef xor_unlock_is_negative_byte -#define clear_bit_unlock_is_negative_byte(nr, p) \ - xor_unlock_is_negative_byte(1 << nr, p) -#endif - -#ifndef clear_bit_unlock_is_negative_byte - -/* - * PG_waiters is the high bit in the same byte as PG_lock. - * - * On x86 (and on many other architectures), we can clear PG_lock and - * test the sign bit at the same time. But if the architecture does - * not support that special operation, we just do this all by hand - * instead. - * - * The read of PG_waiters has to be after (or concurrently with) PG_locked - * being cleared, but a memory barrier should be unnecessary since it is - * in the same byte as PG_locked. - */ -static inline bool clear_bit_unlock_is_negative_byte(long nr, volatile void *mem) -{ - clear_bit_unlock(nr, mem); - /* smp_mb__after_atomic(); */ - return test_bit(PG_waiters, mem); -} - -#endif - /** * folio_unlock - Unlock a locked folio. * @folio: The folio. @@ -1527,7 +1499,7 @@ void folio_unlock(struct folio *folio) BUILD_BUG_ON(PG_waiters != 7); BUILD_BUG_ON(PG_locked > 7); VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); - if (clear_bit_unlock_is_negative_byte(PG_locked, folio_flags(folio, 0))) + if (xor_unlock_is_negative_byte(1 << PG_locked, folio_flags(folio, 0))) folio_wake_bit(folio, PG_locked); } EXPORT_SYMBOL(folio_unlock); diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c index c1de091dfc92..b241b57427b1 100644 --- a/mm/kasan/kasan_test.c +++ b/mm/kasan/kasan_test.c @@ -1097,12 +1097,9 @@ static void kasan_bitops_test_and_modify(struct kunit *test, int nr, void *addr) KUNIT_EXPECT_KASAN_FAIL(test, test_and_change_bit(nr, addr)); KUNIT_EXPECT_KASAN_FAIL(test, __test_and_change_bit(nr, addr)); KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = test_bit(nr, addr)); - -#if defined(xor_unlock_is_negative_byte) if (nr < 7) KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = xor_unlock_is_negative_byte(1 << nr, addr)); -#endif } static void kasan_bitops_generic(struct kunit *test)