From patchwork Wed May 4 17:03:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12838204 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 C4F9BC433EF for ; Wed, 4 May 2022 17:03:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E2816B0073; Wed, 4 May 2022 13:03:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2917F6B0074; Wed, 4 May 2022 13:03:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 182BB6B0075; Wed, 4 May 2022 13:03:30 -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 0A2986B0073 for ; Wed, 4 May 2022 13:03:30 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D4117294C0 for ; Wed, 4 May 2022 17:03:29 +0000 (UTC) X-FDA: 79428681738.01.ED0BD05 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf29.hostedemail.com (Postfix) with ESMTP id 69D951200A1 for ; Wed, 4 May 2022 17:03:24 +0000 (UTC) Date: Wed, 4 May 2022 19:03:25 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651683806; 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; bh=1RqV5nXy8OGsq9YY69kIi1jGnglaqfPXklf8r6Sgiqk=; b=ec7w7Z8FJZA5pFZRwcU8RdsW8qQLv+w6zSWxaxNNBpEyjoVxKaDml0ZAcgiUNlXOhLXYU2 MJA4Fq2J/5drPlXt2qV9ML9GYrBQjvAxMZiWhQrUTs1TMIS4dPLqSsi4E/FeUqJNgeUtqp hPFKyz0sYvYxSSREJbRVj8nF2C5yuyH4PIlcO3C71vnveWZGBWm1Vyf8pi5r6dSf92DE4N iYZEOMzZ9twNfm7wI55YyjK/JQpEldFaIm3dclOeYjO/naH9/YWotu8ZFUzw39CnP/vG/V OKTEfT25lOJpPiq5zcVeEv7qNBifc9m9NVd7cLVkxB702mL8UrWw2k7fVFeRgQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651683806; 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; bh=1RqV5nXy8OGsq9YY69kIi1jGnglaqfPXklf8r6Sgiqk=; b=pIBhm3euS2FoEk4bvVl+fWn6vLhcE3Waj5nKzUbK9ael1OVtUVn/Chg1GfscWUqoXd7uCB Wm8bLCqlALtCoSDg== From: Sebastian Andrzej Siewior To: linux-mm@kvack.org Cc: Andrew Morton , Thomas Gleixner Subject: [PATCH] mm/vmalloc: Use raw_cpu_ptr() for vmap_block_queue access. Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 69D951200A1 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=ec7w7Z8F; dkim=pass header.d=linutronix.de header.s=2020e header.b=pIBhm3eu; spf=pass (imf29.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de X-Rspam-User: X-Stat-Signature: 88gxgnpjjhk3ikjfyin7hcsye33yy9q1 X-HE-Tag: 1651683804-830715 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: The per-CPU resource vmap_block_queue is accessed via the get_cpu_var(). That macro disables preemption and then loads the pointer from the current CPU. This doesn't work on PREEMPT_RT because a spinlock_t is later accessed within the preempt-disable section. There is no need to disable preemption while accessing the per-CPU struct vmap_block_queue because the list is protected with a spinlock_t. The per-CPU struct is also accessed cross-CPU in purge_fragmented_blocks(). It is possible that by using raw_cpu_ptr() the code migrates to another CPU and uses struct from another CPU. This is fine because the list locked and the locked section is very short. Use raw_cpu_ptr() to access vmap_block_queue. Signed-off-by: Sebastian Andrzej Siewior --- mm/vmalloc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index cadfbb5155ea5..41a6e75fbcd8d 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1938,11 +1938,10 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) return ERR_PTR(err); } - vbq = &get_cpu_var(vmap_block_queue); + vbq = raw_cpu_ptr(&vmap_block_queue); spin_lock(&vbq->lock); list_add_tail_rcu(&vb->free_list, &vbq->free); spin_unlock(&vbq->lock); - put_cpu_var(vmap_block_queue); return vaddr; } @@ -2021,7 +2020,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask) order = get_order(size); rcu_read_lock(); - vbq = &get_cpu_var(vmap_block_queue); + vbq = raw_cpu_ptr(&vmap_block_queue); list_for_each_entry_rcu(vb, &vbq->free, free_list) { unsigned long pages_off; @@ -2044,7 +2043,6 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask) break; } - put_cpu_var(vmap_block_queue); rcu_read_unlock(); /* Allocate new block if nothing was found */