Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6776444rwl; Wed, 22 Mar 2023 15:50:29 -0700 (PDT) X-Google-Smtp-Source: AK7set80dn6DNucRYUx+Jr5VQZ2FyaIiltsCWTmSZYhRA6+DGY288hvv6rxUloziZYoTFhDgXXNF X-Received: by 2002:a17:902:ec91:b0:19a:9406:b234 with SMTP id x17-20020a170902ec9100b0019a9406b234mr4711584plg.45.1679525429046; Wed, 22 Mar 2023 15:50:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679525429; cv=none; d=google.com; s=arc-20160816; b=tJa9mRQ+qz+JZ8zfyfIiGbXFP/x+2qVQ6upIlXNYHfMZ38B4GG0HU85z71p+xB2Gs8 RFkoQrezgGqEiOg8F/wZdv+wWVUh/ZeZM0z+F5JJ7rsPwjiLAXRU+O8oqlQ7Zts0YODP bYU1GsNhCglKMzV04UqFGB7tzi8nXUZtYr01GRjqLt1Gju8DEb+M6iYppI1VxwXZ6JWH ZExpffjivmjgbVQx+RppVUTowewJJnitCrMwJeyFnlaYXfkrTfqq1FhKom603sqjeRNw tLLhsBHC32T5ln6AhSAqi5yZmWtEXUHWwEIZ6oQFrZ/W0Zi/ftnth+eZlk0D/V+ZPpxP 5+lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=94IWON34Zkdpip/3iKIcCWqin5aEhz0xQbr2Iwre6K4=; b=LAO0Y8OgZ4DGXGbv3WjYCFBq2r4bXM3Tfm2Ojh0ZfsDoOwf6DcQucVPO7rHGZqJuMJ GvuY1Qnryk58sul3XAE+VX/lKLnvgojctd3bdaibasx38gIeCnv+/a4W4RDQWEira3fh Go1qjzHcYvAYW8YUtvcIxqrTYpbcOPEvJoa6CifMThFlfBkLpF+CR9nKW6aNQzuLrZIL TiGhQ8AwK3oOIhHYFBYH3FD1KRtiYANrHQmQo2HNX3RO+gnnIEWDOfxXFkB0CiUj13JZ DqvnofKGCjM5+L0CCfqEqUYkcTIiH+08OYfleliVyGvoriOEPbdX1a/YHOcAJqBr2Lln esbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=znVzLFVv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="kcB/6idX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a170902d2c700b0019ea0e227f0si18105009plc.296.2023.03.22.15.50.17; Wed, 22 Mar 2023 15:50:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=znVzLFVv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="kcB/6idX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229984AbjCVWtC (ORCPT + 99 others); Wed, 22 Mar 2023 18:49:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229881AbjCVWsy (ORCPT ); Wed, 22 Mar 2023 18:48:54 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7C6E10D4; Wed, 22 Mar 2023 15:48:53 -0700 (PDT) Date: Wed, 22 Mar 2023 22:48:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1679525332; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=94IWON34Zkdpip/3iKIcCWqin5aEhz0xQbr2Iwre6K4=; b=znVzLFVvxK0QXKmCxWwsGvyAuLCqhAi12H3dHGN7dmNkDmSi2VZUFZwHI94sx8b4drrjGB 1Va1hHEuzEFTya75TzCiBPS+byl9Kzb38AZsAeC1towF0vSrD5AchwbohRBPsmULSKrXq5 Fit4lhvrp6ofGiG7aGGCx+ZD7OyDSyJ5ejWFA8DlhUGPZKGp1w0IU9vYisd0IN4ED8SlvF NavX9gv5ZPc7CT5uVunzzOsdmViisnUgXcire9mGP7L06s7WLOlfuorpW2er3u8oRu9puJ qxZUYNeSdbO4mjWnsb6OlgcMRo67HnIPSPumMZAlP7d3YyhfruXyueox6iAhnQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1679525332; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=94IWON34Zkdpip/3iKIcCWqin5aEhz0xQbr2Iwre6K4=; b=kcB/6idXSj7OcRYvXO4RkBvWsFtNVPfHkpnK2LstwClo9SvOAgsf0/lM5sa0aZfh/RjInr kCuxlst7ioJV5/AQ== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] livepatch: Convert stack entries array to percpu Cc: Josh Poimboeuf , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230313233346.kayh4t2lpicjkpsv@treble> References: <20230313233346.kayh4t2lpicjkpsv@treble> MIME-Version: 1.0 Message-ID: <167952533158.5837.17769419178497550655.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: e92606fa172f63a26054885b9715be86c643229d Gitweb: https://git.kernel.org/tip/e92606fa172f63a26054885b9715be86c643229d Author: Josh Poimboeuf AuthorDate: Mon, 13 Mar 2023 16:33:46 -07:00 Committer: Peter Zijlstra CommitterDate: Wed, 22 Mar 2023 17:09:28 +01:00 livepatch: Convert stack entries array to percpu The entries array in klp_check_stack() is static local because it's too big to be reasonably allocated on the stack. Serialized access is enforced by the klp_mutex. In preparation for calling klp_check_stack() without the mutex (from cond_resched), convert it to a percpu variable. Signed-off-by: Josh Poimboeuf Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20230313233346.kayh4t2lpicjkpsv@treble --- kernel/livepatch/transition.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c index f1b25ec..135fc73 100644 --- a/kernel/livepatch/transition.c +++ b/kernel/livepatch/transition.c @@ -14,6 +14,8 @@ #include "transition.h" #define MAX_STACK_ENTRIES 100 +DEFINE_PER_CPU(unsigned long[MAX_STACK_ENTRIES], klp_stack_entries); + #define STACK_ERR_BUF_SIZE 128 #define SIGNALS_TIMEOUT 15 @@ -240,12 +242,15 @@ static int klp_check_stack_func(struct klp_func *func, unsigned long *entries, */ static int klp_check_stack(struct task_struct *task, const char **oldname) { - static unsigned long entries[MAX_STACK_ENTRIES]; + unsigned long *entries = this_cpu_ptr(klp_stack_entries); struct klp_object *obj; struct klp_func *func; int ret, nr_entries; - ret = stack_trace_save_tsk_reliable(task, entries, ARRAY_SIZE(entries)); + /* Protect 'klp_stack_entries' */ + lockdep_assert_preemption_disabled(); + + ret = stack_trace_save_tsk_reliable(task, entries, MAX_STACK_ENTRIES); if (ret < 0) return -EINVAL; nr_entries = ret;