From patchwork Tue May 23 14:02:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 13252421 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 4A4BFC77B7A for ; Tue, 23 May 2023 14:10:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5715280002; Tue, 23 May 2023 10:10:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D071B900002; Tue, 23 May 2023 10:10:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCFAF280002; Tue, 23 May 2023 10:10:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id AF6B8900002 for ; Tue, 23 May 2023 10:10:14 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7A0171C73F3 for ; Tue, 23 May 2023 14:10:14 +0000 (UTC) X-FDA: 80821704348.26.F35AF1A Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf14.hostedemail.com (Postfix) with ESMTP id 278001003F2 for ; Tue, 23 May 2023 14:02:17 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=FNHzUr4n; dkim=pass header.d=linutronix.de header.s=2020e header.b=CM3GaqCW; spf=pass (imf14.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684850538; 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-type:content-transfer-encoding:in-reply-to: references:references:dkim-signature; bh=Ibnqpyl4Lb4JYp4nO/JxOZHxvcUh8VlC1ZH296mXXb8=; b=vPZ3TaZfJRTlCSkq8r16dmvrxanrAaDvlJBkfIRtFWntS+mNFTlBwdPfDLKI6mRtC/vlre yILp3JKuHco9rMxaMmbqxE0pXNFlhw4G+O7ysw+mBgs2NKkcteNkEbsLmNij1bmbEUeWCr jIP9YEOEepp429Fe0Tsa/lCSPdFLWRA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684850538; a=rsa-sha256; cv=none; b=uEc1+7bshPAWSd0p6P1s2NcrTWwsYcOyDsyqDAuK689rRzj5gCziQLjnkAi3NQcJi8cCmM eMFzo7ATijY0kV/y2r/IwLkAmtzicqMz2he39/u0IV52nnfWQ6Y0fpK4nRPC+7NGt9qidS jAzp1dbqZNDg4AV0ncs6BIECzOL2xr0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=FNHzUr4n; dkim=pass header.d=linutronix.de header.s=2020e header.b=CM3GaqCW; spf=pass (imf14.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de Message-ID: <20230523140002.799808756@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684850536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Ibnqpyl4Lb4JYp4nO/JxOZHxvcUh8VlC1ZH296mXXb8=; b=FNHzUr4nuDzZ128tl2CzhpkmPH9AVm9WZ2Z/CcDIN9dhVaS2d7TIQ9H3qASuPvEWl1TJCH +uNPlqu6p2D9CExxrB2JvU1NXvOSgX90tLmAdCohqOVx3+KXbSsyN7KTwWJhNetXR7fBzB nxaw3KTjIkukTHO+71MbTk4YaN0uwIF+ZRBAwN+QsLWPttY9OAGQaQaeQ7Buw8S0biDOFr UYUAtslxjjoFmpgKFvZcqGk1wRkZu+Gmn1MO5ty57aLybljms6naFsIvDK6AjxTPLORnKK aJyKSqL1ltAqigkaOQx6LxiVPDITRpK1gZq6wNLv6TaJ/fOc8b0hJnmcDSFdew== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684850536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Ibnqpyl4Lb4JYp4nO/JxOZHxvcUh8VlC1ZH296mXXb8=; b=CM3GaqCWE3ECvjI41+TwoJcXImXmhvO/ypN4ZfIpuQRQwa4lsAQN6+RAODV3UFyUc8zd0o JGCTd1bKfvd0/kBA== From: Thomas Gleixner To: linux-mm@kvack.org Cc: Andrew Morton , Christoph Hellwig , Uladzislau Rezki , Lorenzo Stoakes , Peter Zijlstra , Baoquan He Subject: [patch 5/6] mm/vmalloc: Add missing READ/WRITE_ONCE() annotations References: <20230523135902.517032811@linutronix.de> MIME-Version: 1.0 Date: Tue, 23 May 2023 16:02:15 +0200 (CEST) X-Rspamd-Queue-Id: 278001003F2 X-Rspam-User: X-Stat-Signature: m9oah5poh7nsddezoku3rnh1s9eizupu X-Rspamd-Server: rspam03 X-HE-Tag: 1684850537-469136 X-HE-Meta: U2FsdGVkX1/yeqkfUX5+0PnfxWIr+Zj8zFTqs6CDEBOT3KjYXzzbNFF9ZJG9Z23fmbp6b1t3f8ZctwcMKxsnA1/8VdsL0y7m1imt+fGAZrL/fVkUQ9nwuqXFbP89gWaXByCYSFnNOqS1eRlR3/HoKuTqU0NIQPwtucOPVXRVe6GlxYVBhykkBOlg918Go3VhtZZXUxG/wPx9XrnFFIV3ttqgH86ArPUIYmIvyW0mHOF1q5i8xZqcIaB8t6WSUdQoCbWPfXU768IScIFCWiMCx4EX0DK2Q4uS9E5ihZYx9qruFCS909vj5MJwmtrLMewvBXMKjv24to4g+jWdfEBnlAK9a1y/h5ZECntTLTRcSJvO1bF8Yc+5zGq9NRNapMbpHBiAmvW1XZO7sy5EPQ4lc4VcwKrRf6dgG4m1v11nvP6fzSye04D+Oti8j+HDUUC7uWf6uH2w0vJ64cb597UEyXjHNPA0iTTAjbsIAKIVGAoES4ORZ/q4iD7TV9+tkk5JSQ3bfsnqX82qTmP+cCogbuwBBrGz/PFMEvjzInfKJQ1ThmuYsKdrcUhbHI9Rplv6KsD+T+Nf0rhoHdcmAgkADxgJ0ImtPZzZHI02cMG4CkCavemHE5GLunNN6X9K5aAkWpCZpOwT9Q90tHNAasrwLsfjYmsG0CKx1VhfKHUW1eVz+QoB3RLmLQuLpYvj+KkyERjx0ZvJllBnsSpXe8dHKIU0SkpTm7rirvUdfp6xht4sesLw/zLRltr1KFxhq3YfChhbPm2T5Rxn3uXMPcEgl6PYbLToDMFDdCFjhGfGTikpzByxAGYGvxH4enoPMCdlanYXs5vrwv/rrnySYPYW1BpqmjjqXPfDtMbpiWIXeUcDQXaPV3mvxbPc3ANdid0rOzyWN7g9TW6XbXCJGBw8YeTNwO8X82XI/Mupd25FwEtVrb8+K9IL6YMaNieCFz/32XasEPut7kPDKrphPTn +Nvyd9by ioTJyJbDWeA2mHDIABkxiMOyIZU6TuDczMfbmHgDehvJYkx9rBdp4CEv6YQiZfGLrqEIO7JbRzkBjHnoE5lhKp5BbQXTC4m/++fOpePS9mF4KT/8l1vKgjOM9mRD/9JoXIjMPru7Kt8cSKlQ= 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: purge_fragmented_blocks() accesses vmap_block::free and vmap_block::dirty lockless for a quick check. Add the missing READ/WRITE_ONCE() annotations. Signed-off-by: Thomas Gleixner Reviewed-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2093,9 +2093,9 @@ static bool purge_fragmented_block(struc return false; /* prevent further allocs after releasing lock */ - vb->free = 0; + WRITE_ONCE(vb->free, 0); /* prevent purging it again */ - vb->dirty = VMAP_BBMAP_BITS; + WRITE_ONCE(vb->dirty, VMAP_BBMAP_BITS); vb->dirty_min = 0; vb->dirty_max = VMAP_BBMAP_BITS; spin_lock(&vbq->lock); @@ -2123,7 +2123,10 @@ static void purge_fragmented_blocks(int rcu_read_lock(); list_for_each_entry_rcu(vb, &vbq->free, free_list) { - if (!(vb->free + vb->dirty == VMAP_BBMAP_BITS && vb->dirty != VMAP_BBMAP_BITS)) + unsigned long free = READ_ONCE(vb->free); + unsigned long dirty = READ_ONCE(vb->dirty); + + if (!(free + dirty == VMAP_BBMAP_BITS && dirty != VMAP_BBMAP_BITS)) continue; spin_lock(&vb->lock); @@ -2231,7 +2234,7 @@ static void vb_free(unsigned long addr, vb->dirty_min = min(vb->dirty_min, offset); vb->dirty_max = max(vb->dirty_max, offset + (1UL << order)); - vb->dirty += 1UL << order; + WRITE_ONCE(vb->dirty, vb->dirty + (1UL << order)); if (vb->dirty == VMAP_BBMAP_BITS) { BUG_ON(vb->free); spin_unlock(&vb->lock);