From patchwork Mon Mar 20 18:03:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13181696 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 16E5EC7618A for ; Mon, 20 Mar 2023 18:12:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C31116B0088; Mon, 20 Mar 2023 14:12:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF3B76B0089; Mon, 20 Mar 2023 14:12:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 946CE6B008A; Mon, 20 Mar 2023 14:12:17 -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 82D2E6B0088 for ; Mon, 20 Mar 2023 14:12:17 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 617511C67A0 for ; Mon, 20 Mar 2023 18:12:17 +0000 (UTC) X-FDA: 80590071114.29.383D56E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id AC64F16001C for ; Mon, 20 Mar 2023 18:12:15 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MXN+sq0N; spf=pass (imf08.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679335935; 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=wO6Kd7Y8EK9tLPzGQ8Uve+plh0sOV79AJsB8xhd25oc=; b=y3lF9ndzHCqh0TrQF0BjeRZBuLo88eWazRzWfsxaF7JjPROhh/AVUWhQsKO6pjBN3oBuPe T8YMq/eDT1U44WjBjz4HqQqk1vZH2NNnJu31WQ5Wr+LrXCgSArNj8Huz23KBa9CEtTqZAw rE6AkR/G5ZBFcyte/nU56i84kNG1KeM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MXN+sq0N; spf=pass (imf08.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679335935; a=rsa-sha256; cv=none; b=z+9xYAB7FHa6CFCUcMDwMvOdhIkbVbst0tWlR9/eBik79P8i9O6u7ifDaaYlwGNm+4psjc x4FwNUaGaa+aqJtbnfznzyw6bj9rk1dx2NEmpCyq+AsRykE958la7kGXtRymhW/GPvEi3s n0fso3cNXwMmNlupYHcy/S99TfRLaGo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679335935; 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=wO6Kd7Y8EK9tLPzGQ8Uve+plh0sOV79AJsB8xhd25oc=; b=MXN+sq0NTZEXSaWQAGELNTCjVSmU6ico/xAhnaYW7cUqWcIhKwYv1lZVo6LcZI7eAlZyr4 dqhd0k0DoGQM0j69oEkZT1qhk+PjKwMAQhmZoiarcJclj7x6OW/yqyIhKDXmcDRGSZneJ2 cOnZRIiz4QyfHnyEr3G3mVwRz7IfVPE= 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-437-tjxg_1SWOlK-KVT9IU19TA-1; Mon, 20 Mar 2023 14:12:09 -0400 X-MC-Unique: tjxg_1SWOlK-KVT9IU19TA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 814FC100DEAD; Mon, 20 Mar 2023 18:12:08 +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 A6E57483EC4; Mon, 20 Mar 2023 18:12:07 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id E93FF403BC8B7; Mon, 20 Mar 2023 15:08:02 -0300 (-03) Message-ID: <20230320180745.709381791@redhat.com> User-Agent: quilt/0.67 Date: Mon, 20 Mar 2023 15:03:39 -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, Vlastimil Babka , Michal Hocko , Peter Xu , Marcelo Tosatti Subject: [PATCH v7 07/13] convert this_cpu_cmpxchg users to this_cpu_cmpxchg_local References: <20230320180332.102837832@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: AC64F16001C X-Stat-Signature: 5uea7km1u7zu6oasttk8jxxijh5go8y6 X-HE-Tag: 1679335935-129782 X-HE-Meta: U2FsdGVkX1+YtB5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xipj156GLLn6kJSf8vcmKi7mlL0QvzbHyVJnnyl2LmzCpF8Pmww6/8EPFfYuAvR7xiP99QwU7hmr6d3Ou2NdvTmR0dADwfJptvEaody1GsAg== 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);