Received: by 10.223.164.221 with SMTP id h29csp41057wrb; Fri, 3 Nov 2017 10:08:32 -0700 (PDT) X-Google-Smtp-Source: ABhQp+R6PGQ+NBsM8hae4nrGPTxRRu7231o9jTB2HIpZbfzNvsi0ge5YXxDNyp3HDmqJAsZy0fy3 X-Received: by 10.159.253.9 with SMTP id p9mr7335272pls.344.1509728912300; Fri, 03 Nov 2017 10:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509728912; cv=none; d=google.com; s=arc-20160816; b=UrXvh7cOSPSfQNddnG8lIKTCjf2iIcATumpewGJ0cWw/4nP+CQRLomsZDUS9VMyUCu 2HJnCMJq5JodoM2AW6yyUsy1k/48nkue59KlPVuTG67exVhIwnvsnR7Y5u179hFjO0rx uH9fd9XBNLNdOP9glNtMOPnpBnGk5dTYw51zHKk7FFk9Y7ra+7jGLhMc7xZgiHQYGU3Q 4gspf9P3cJyWxGToAQNJRdJhukT6sKfoQfrxdUsb6WyJJQiBBhjJv9SKB0OPrrodaJ6C pZI/SWTDPC2G+JTdDubwCNBY+beBOX7HbB7kaz26z/b9IOhu6dqju2tEutMFHlcZmQ0e Uf7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=4YMYrFROp3pc6isOqHPvnWFCPOUwOfkEiSX6JjUUwOM=; b=JyONhRAzzLynyAC0uHN+olKbYW71TMCF5kNR+pYl5x7gaIL8GSdKpcaNkZFY4zVmbd JGyjwhblnKwUSR6vz2rSoHR9q2OmQeclSkuAUjE3AvTKJYHwKLzp8QuLucpBAphoL00C XPhv8rrGBFZHFa4e3X5ME+ph9E2ToBzOoDD4wgFxRHPJvIuMDTlVdI19XAcNBES8rWws ZUdkvjhInWY7mcsM7umuLUR81+Yhus+rOFm0q4EyM6W1SAtQ7IbRgUwsll0aBgxfONPt UqUVx0WXcnqDchA8Kia23okppyGLxqxDVhoJIQg8o7ykKswEn7+qGGhan45OVlqTegTM bOYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g66si6875686pfj.184.2017.11.03.10.08.19; Fri, 03 Nov 2017 10:08:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933288AbdKCRFU (ORCPT + 93 others); Fri, 3 Nov 2017 13:05:20 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:56190 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756252AbdKCRFK (ORCPT ); Fri, 3 Nov 2017 13:05:10 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from cmetcalf@mellanox.com) with ESMTPS (AES256-SHA encrypted); 3 Nov 2017 19:05:06 +0200 Received: from ld-1.internal.tilera.com (ld-1.internal.tilera.com [10.15.7.41]) by mtbu-labmail01.internal.tilera.com (8.14.4/8.14.4) with ESMTP id vA3H554x008337; Fri, 3 Nov 2017 13:05:05 -0400 Received: (from cmetcalf@localhost) by ld-1.internal.tilera.com (8.14.7/8.13.8/Submit) id vA3H55cl010518; Fri, 3 Nov 2017 13:05:05 -0400 From: Chris Metcalf To: Davidlohr Bueso , Oleg Nesterov , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Andrew Morton , Rik van Riel , Tejun Heo , Frederic Weisbecker , Thomas Gleixner , "Paul E. McKenney" , Christoph Lameter , Viresh Kumar , Catalin Marinas , Will Deacon , Andy Lutomirski , Michal Hocko , linux-kernel@vger.kernel.org Cc: Chris Metcalf Subject: [PATCH v16 04/13] Add try_get_task_struct_on_cpu() to scheduler for task isolation Date: Fri, 3 Nov 2017 13:04:43 -0400 Message-Id: <1509728692-10460-5-git-send-email-cmetcalf@mellanox.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1509728692-10460-1-git-send-email-cmetcalf@mellanox.com> References: <1509728692-10460-1-git-send-email-cmetcalf@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Task isolation wants to be able to verify that a remote core is running an isolated task to determine if it should generate a diagnostic, and also possibly interrupt it. This API returns a pointer to the task_struct of the task that was running on the specified core at the moment of the request; it uses try_get_task_struct() to increment the ref count on the returned task_struct so that the caller can examine it even if the actual remote task has already exited by that point. Signed-off-by: Chris Metcalf --- include/linux/sched/task.h | 1 + kernel/sched/core.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h index 270ff76d43d9..6785db926857 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -97,6 +97,7 @@ static inline void put_task_struct(struct task_struct *t) struct task_struct *task_rcu_dereference(struct task_struct **ptask); struct task_struct *try_get_task_struct(struct task_struct **ptask); +struct task_struct *try_get_task_struct_on_cpu(int cpu); #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d17c5da523a0..2728154057ae 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -670,6 +670,17 @@ bool sched_can_stop_tick(struct rq *rq) } #endif /* CONFIG_NO_HZ_FULL */ +/* + * Return a pointer to the task_struct for the task that is running on + * the specified cpu at the time of the call (note that the task may have + * exited by the time the caller inspects the resulting task_struct). + * Caller must put_task_struct() with the pointer when finished with it. + */ +struct task_struct *try_get_task_struct_on_cpu(int cpu) +{ + return try_get_task_struct(&cpu_rq(cpu)->curr); +} + void sched_avg_update(struct rq *rq) { s64 period = sched_avg_period(); -- 2.1.2 From 1583083259778699206@xxx Fri Nov 03 21:50:45 +0000 2017 X-GM-THRID: 1582126742408023281 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread