From patchwork Wed Mar 22 22:48:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 73691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2614812wrt; Wed, 22 Mar 2023 16:01:05 -0700 (PDT) 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" X-Google-Smtp-Source: AK7set8VMxWL8KiGtg1RkYamGdVNwWDaJ2jalPHN57JpzU0UvPo0Fvj7V8u5u8grov6GLu0s4/ik X-Received: by 2002:a17:903:32c3:b0:1a1:80ea:4352 with SMTP id i3-20020a17090332c300b001a180ea4352mr5176815plr.0.1679526065249; Wed, 22 Mar 2023 16:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679526065; cv=none; d=google.com; s=arc-20160816; b=ZK1wNXqk5AL9xoBhT/c8IjPUMJMRryOOXx9X9h21M7/vg6xlr+F2nzDdm6qq4nFHyB arw3oJ6/YDHXRI0DeAFfY0a3W8ZuFTeDAe449lqUZQdO1Ei0KAuOKe/KUc7duE7EIxZO 33Jbku3RpGXYtWxfeQ0NHsFFx8AT0uxYIrdI3n5eAAAOJaQtvYHBo/qL/y1xCMGTx6iL jRNn2JmtROmFqX3Vbv7KcC2weapO0lts9bXsUV9Sfyu7n5zT/N/8rYJxpICt5n6NrqjW 3uAWjc/+1y5DGMzWKUnF5NsOEXerm9X+ONNGyuC2pSfVWVd4UIz8TRL5KfJ20NcycGdO 6/bA== 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.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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a17090a67c900b0023d0b62c65bsi92575pjm.126.2023.03.22.16.00.51; Wed, 22 Mar 2023 16:01:05 -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.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 S229941AbjCVWtC (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760299602950990796?= X-GMAIL-MSGID: =?utf-8?q?1761110723665646676?= 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;