From patchwork Thu May 25 12:57:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 13255209 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 4DE20C77B7A for ; Thu, 25 May 2023 12:57:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71903280003; Thu, 25 May 2023 08:57:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6CA59280002; Thu, 25 May 2023 08:57:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BAD9280003; Thu, 25 May 2023 08:57:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 34D4C280002 for ; Thu, 25 May 2023 08:57:12 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F35CA1C737D for ; Thu, 25 May 2023 12:57:11 +0000 (UTC) X-FDA: 80828777862.11.646FB95 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf23.hostedemail.com (Postfix) with ESMTP id 3C76514001B for ; Thu, 25 May 2023 12:57:09 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=uXMSCRUo; dkim=pass header.d=linutronix.de header.s=2020e header.b=kp28YZKh; spf=pass (imf23.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=1685019430; 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=ze7oyOSqZQkkVBNsE/8CNWjfH2V5Y7y7n3jv3AIkJWU=; b=dM6FSwIGIGAmcrar/9+SmUzG0bq1ftTCCiK2K+kqAexnM3aPglum8KJbGHKlSF7R43rkwG KXk4SXG+5Qy7dM7l9gqCX0q9gJugAuFkffVuMve+ZwqTs8HRjlpCIyvVR+gEeSeQRo8Mtl 9n7CuYnT6JRBVFS//B01d16a3gLLHLs= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=uXMSCRUo; dkim=pass header.d=linutronix.de header.s=2020e header.b=kp28YZKh; spf=pass (imf23.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685019430; a=rsa-sha256; cv=none; b=29071F3QaGAhJIdqcQCSNw8fdjU/FV3w4Sgxx+cqnB0SbvrKipHwRzG+GOE6qgDaEF77VR qvjAUeb72kSBwA4GQ8YdWH0fWXNAhTfWkbvFrDXWBS+YImfM8S9ZT48dn0ZxEfswk+bm0P dkCcthy6/Nge1b9W1l7w2Hq/JxYFaXY= Message-ID: <20230525124504.807356682@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685019428; 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=ze7oyOSqZQkkVBNsE/8CNWjfH2V5Y7y7n3jv3AIkJWU=; b=uXMSCRUo2T9j5sQKMTrPEPWgMSapFR4l2yGg+q8O745ZIlK+9jc7TXY73rVJqW82x2M6oO mjX0WDMK3DnQdD+GM6i+dLJ2fnqmzDpyB8fJv7ttkACl5vGiPGtHINe2vJWHa8ikM4sE5c MNpCpopGrPOro1BGS/CBkll85JlWeEYF7U7YH/zdWzjE7Bk5O7Bs4JuqMoHfi1/hRiCKuV A5kINwSdwGmSwTLtoa3FEXRrmGOV6PyBaGsgkCuNiG+BrxTSwuN3UnHc/e0NATqzEW5rw2 AK5aP0ghXQDiLOtHmkY8VR+coRjmoi+HVLviE2g7FcRKi9Ow/a/SG1YfNR2M4g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685019428; 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=ze7oyOSqZQkkVBNsE/8CNWjfH2V5Y7y7n3jv3AIkJWU=; b=kp28YZKhnSQyP1pwMtHm3vHfBL90++rU86ht3qOwP/rD5axI34ruN2bQ4tUjVVEAOyqVHV 8M8mafcR8osybHCg== From: Thomas Gleixner To: linux-mm@kvack.org Cc: Andrew Morton , Christoph Hellwig , Uladzislau Rezki , Lorenzo Stoakes , Peter Zijlstra , Baoquan He Subject: [V2 patch 5/6] mm/vmalloc: Add missing READ/WRITE_ONCE() annotations References: <20230525122342.109672430@linutronix.de> MIME-Version: 1.0 Date: Thu, 25 May 2023 14:57:08 +0200 (CEST) X-Rspamd-Queue-Id: 3C76514001B X-Rspam-User: X-Stat-Signature: zq4i7ugm3ypjpaog75jrr5u4ddeed6yn X-Rspamd-Server: rspam01 X-HE-Tag: 1685019429-930031 X-HE-Meta: U2FsdGVkX188DJ/RBbAHKwWoFAbOPc3NgNrLvvzmZSG9AB/bx6L+4MBXZBsIbN8Lf5tU9Odp/ky+NmIkbBsQse4F7xZEXgU19GLo92LNuqqjZ/Wwyhs5FWDloI6XH9t9Z1DKcCpwo80fFiYN+/ErV/C+fuD6WMw5ILifpZM3XOt3bYeqe/O9umep4t5bidr6k64rst3A6/14vPdzBknHW++7Vzmd7YshExTg2myTFaq9IQfUfe166jRDnDXJEn9C1B8MQ6mLtU+ymEonW81SZsb5POmdyQDTDQMLRoIo2uVuJ9JMjETwik2XC973PkqjbpSJUyy7+9K9//DAV3J+MK2sZIDbK08PGSGi8raziq50uXvuq1ruP66zY8PcYtjUWzPbfdsegChfPQN3Y8jdl92jljhRNeKbyxBmpps1uRNtwOtioGVP0BoazO70zoTAhKVLzGAfIZ0pq5TgVSb8tVqjVHYqk/605jnCCoeOa+3Ec5ZCp5w2SUDU8Mzgms/7Mxio6aaRHa+/xSEW3N+XRnn+516Mwtcr7lygMUi3bP3sJ4CTSxIKQR44rFYZNWqSQVbWzVKhV5huV3tR2eElFG9e65wczCni/EPdilOr0ScvLyf5OI6QBp7F2iNqk2p/GJKZNT3It1UX40nfpX4eQA74+e2mUl/FO5i7uQpbfzaIGlmh0fIbA6g9h+ZdBMWkKY1ub9RumrQQrecgMWOxm6OaNn2PNZANNQHLWU/pPCY5Mzl/8omiQLKvP5OVDMsYhI6esnBIp/EXCbnYdbXbWo8mnZwrjFibF50D2CE49x9Efw4c2A5XP1KRtqt3101omeA43n7GDakhR9dsKyQr38bOg9rKaq6C9TJscme8AqxgBH2MtjbXZuFLR09EKMu2Z0rw7UYIhRAZEURSJ+wNnkcZvIVnR4ypHCXI2P0tk5YaH4VDfpHc4Ax0NdHkfZHnPMzGV3v9XCH/ehDs+BL 1HrBofrD +854WwLWAyZiifatEKI1p50QfPKLx6o5U4U9np0KSqGDLUvpQN8zA6ynX+xeuY7H0OddwD1Ra89CuFTLISO62FV8PrgbrJmr5FguxImWysIxZv2lQwrK2b8dtvOAkfUG05Ld3ooxnCv7Ak6+hETy0dpDr0uOe0fXv+0F8D8xqjbIZYfo= 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) Reviewed-by: Christoph Hellwig --- mm/vmalloc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2094,9 +2094,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); @@ -2124,8 +2124,11 @@ 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); @@ -2233,7 +2236,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);