From patchwork Sun Mar 5 13:37:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13160147 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 0A910C6FA8E for ; Sun, 5 Mar 2023 13:42:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4D076B007D; Sun, 5 Mar 2023 08:41:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B881A6B0081; Sun, 5 Mar 2023 08:41:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B7246B0080; Sun, 5 Mar 2023 08:41:51 -0500 (EST) 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 3358B6B007D for ; Sun, 5 Mar 2023 08:41:51 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F1D6EAABA3 for ; Sun, 5 Mar 2023 13:41:50 +0000 (UTC) X-FDA: 80534957580.11.69E6E61 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 51F4720006 for ; Sun, 5 Mar 2023 13:41:49 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dJ4oCxam; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678023709; 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=4jas7+kZOWWtovsxw7rARjyOL6nO08FiGsNhXOwYk0U=; b=4iPuBVChDm+48S6jOuQroGvXxk7UdRxMt67FdkHO31qDpGcheBSy/F/VK2ruckBwMiovKE BrONVBOe9DxpeM3KDrnU9bkilk/9F5FHHnzrHmj7JJTttrvzQFQbqiO6cR9rLa3elgTMxb PAYRPjrFj/JugUgGbSa8X6IofL6Dcl0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dJ4oCxam; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678023709; a=rsa-sha256; cv=none; b=ZGc0nLGO7QYsflVg+eUHmuX3mRVslEfEyYu+gxojOsAXyCb6aJGSIajCv9Io/QFzClGQrv B+P/XvrMnW8xaG34yUjT7cLc4yzm8OrUFCRSi9tv5ub3fh3SEysz2BLX5zgW96eXuR0eFI NEEh5SFZUQWHdxBlD+0+9Mp4TrDX6ac= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678023708; 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=4jas7+kZOWWtovsxw7rARjyOL6nO08FiGsNhXOwYk0U=; b=dJ4oCxamnSSAJS5qySE2URIZktV88L3KwJ2Z5EL8F9hQDGAa7JeN7syCktRTRXqN/04AWq RT0j+jrQZQcK5/asdvRXWPHN7g67uBN/VAVCh0QiI1gSFta5lDeD1WFUTlL860t8R8mViM gdaXPs2SLLZOANXV4cdj3gzZZrSlhBg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-562-8iJu-gaUM3O6uf58ubxlWA-1; Sun, 05 Mar 2023 08:41:45 -0500 X-MC-Unique: 8iJu-gaUM3O6uf58ubxlWA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D9AD7101A52E; Sun, 5 Mar 2023 13:41:44 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A647D14171C3; Sun, 5 Mar 2023 13:41:44 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 2F3B7401A0FEE; Sun, 5 Mar 2023 10:41:23 -0300 (-03) Message-ID: <20230305134053.587741722@redhat.com> User-Agent: quilt/0.67 Date: Sun, 05 Mar 2023 10:37:04 -0300 From: Marcelo Tosatti To: Christoph Lameter Cc: Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Russell King , Huacai Chen , Heiko Carstens , x86@kernel.org, Peter Xu , Marcelo Tosatti Subject: [PATCH v4 07/12] convert this_cpu_cmpxchg users to this_cpu_cmpxchg_local References: <20230305133657.255737580@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Queue-Id: 51F4720006 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: mtoqt1wupz1wy9wg8zar4e1pkcti8q74 X-HE-Tag: 1678023709-665016 X-HE-Meta: U2FsdGVkX1/GE4V6Nw1yzWQvO97wOj05vYWr+w7B3EVg09yIRi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XmkVvHapte+yysrdka3O8zhfUVf421BLs+pdo35N4OhyOulVk5bPj9G3KXRYkCUAreP/Gn0i093e8CPHlLRBm3tF0S8k9qT7zv31s16cY8xbse5fXI/Gnf2Gz5Jw== 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: this_cpu_cmpxchg was modified to atomic version, which can be more costly than non-atomic version. Switch users of this_cpu_cmpxchg to this_cpu_cmpxchg_local (which preserves pre-non-atomic this_cpu_cmpxchg behaviour). Acked-by: Peter Xu Signed-off-by: Marcelo Tosatti Index: linux-vmstat-remote/kernel/fork.c =================================================================== --- linux-vmstat-remote.orig/kernel/fork.c +++ linux-vmstat-remote/kernel/fork.c @@ -203,7 +203,7 @@ static bool try_release_thread_stack_to_ unsigned int i; for (i = 0; i < NR_CACHED_STACKS; i++) { - if (this_cpu_cmpxchg(cached_stacks[i], NULL, vm) != NULL) + if (this_cpu_cmpxchg_local(cached_stacks[i], NULL, vm) != NULL) continue; return true; } Index: linux-vmstat-remote/kernel/scs.c =================================================================== --- linux-vmstat-remote.orig/kernel/scs.c +++ linux-vmstat-remote/kernel/scs.c @@ -83,7 +83,7 @@ void scs_free(void *s) */ for (i = 0; i < NR_CACHED_SCS; i++) - if (this_cpu_cmpxchg(scs_cache[i], 0, s) == NULL) + if (this_cpu_cmpxchg_local(scs_cache[i], 0, s) == NULL) return; kasan_unpoison_vmalloc(s, SCS_SIZE, KASAN_VMALLOC_PROT_NORMAL);