From patchwork Thu Jan 13 23:39:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Oskolkov X-Patchwork-Id: 12713194 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 8FC17C43217 for ; Thu, 13 Jan 2022 23:40:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F9416B007D; Thu, 13 Jan 2022 18:40:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 184D96B007E; Thu, 13 Jan 2022 18:40:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 008596B0080; Thu, 13 Jan 2022 18:40:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0037.hostedemail.com [216.40.44.37]) by kanga.kvack.org (Postfix) with ESMTP id D9F3C6B007D for ; Thu, 13 Jan 2022 18:40:15 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8DBA48F6F7 for ; Thu, 13 Jan 2022 23:40:15 +0000 (UTC) X-FDA: 79026884790.03.0BC8CEC Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf06.hostedemail.com (Postfix) with ESMTP id 1ABC0180004 for ; Thu, 13 Jan 2022 23:40:14 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id u185-20020a2560c2000000b0060fd98540f7so14880135ybb.0 for ; Thu, 13 Jan 2022 15:40:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=M6CqLRKobTxmQJYwGP116eObFPKtwslTaqzW/rSJTK8=; b=qMGBjdhvTEK6hecBGOuRoK6F9ospIcTv+bSkzHtDzzW7elpIvv8C06+6MKkfz7rono PuJSCFA3CXEtek3Rf9jxxOyl/l7tTBEZ04+rY1/G7T+btp87CZdeFeT3eLx7mSuseTHi iUvCt0mbOOYItyWq9/z/yf7UhMvCB6omSP+9cILENtov+4CzMlPKk4ChS/CCDgOGcR7x rYu6FH+COfsfs2ihA+0r4LYfiiAGOXB0NDa+BWnm9ZmHakjHKtseaH4QESWTp8WFfWnH 58XhmuiKFvO8OPBHefgWNMoqmUWy+6FE+BPuXyneucVFuZG5qCO1pP3RrHlwIjnG+ltC yX+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=M6CqLRKobTxmQJYwGP116eObFPKtwslTaqzW/rSJTK8=; b=CfNnrIEXYSdQQj8VqI6Ow65XK/ej9ZDPO1d7Ce/Elfd6stt+Vtk+8vM/hlDPSX15gK c+XqPcizs1+/1vZZHPLD74cxrmr0P0QDIvso/eaiWQtoCCWpGXPb4+3xps+pcfXL6wuP NNR15Mp1rN7mr6NC2prlOvQmrojQ8Ypni4/FvbpVaqoBLLoXHPUh9dt214F87ETgw8W1 FrFkpljy95BK1J4bdqnsyGgk7+wnm4yvinPPTDAZuuw2rT0D8ZKBHIRvTkLZ8qZ9FYDE h5tcrPeSJFUssmWwBd8VhSrCWhCHp/EraMGKBzsQOp0lN/8J4LOcneHFXYI8VRwZCZNQ vt4Q== X-Gm-Message-State: AOAM530QfMpXlCt+rLoSBWo8OfOkVPCYSUJbIMvYJwFaNnbmTrXP/VLZ DxwS7WkKNWf0SjUYphEwrDMl7je/ X-Google-Smtp-Source: ABdhPJyMyvqiBBmhkwL82olAcxjEEcUWe5ozz1YnPt/AtCMregTQoiHsk98ChHrmtDs/+uO8eeFVk5cL X-Received: from posk.svl.corp.google.com ([2620:15c:2cd:202:c548:e79f:8954:121f]) (user=posk job=sendgmr) by 2002:a25:ae8b:: with SMTP id b11mr9266950ybj.453.1642117214365; Thu, 13 Jan 2022 15:40:14 -0800 (PST) Date: Thu, 13 Jan 2022 15:39:40 -0800 In-Reply-To: <20220113233940.3608440-1-posk@google.com> Message-Id: <20220113233940.3608440-6-posk@google.com> Mime-Version: 1.0 References: <20220113233940.3608440-1-posk@google.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog Subject: [RFC PATCH v2 5/5] sched: UMCG: allow to sys_umcg_kick UMCG servers From: Peter Oskolkov To: Peter Zijlstra , mingo@redhat.com, tglx@linutronix.de, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-api@vger.kernel.org, x86@kernel.org, pjt@google.com, posk@google.com, avagin@google.com, jannh@google.com, tdelisle@uwaterloo.ca, posk@posk.io Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=qMGBjdhv; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of 3XrjgYQQKCGcUTXPLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--posk.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3XrjgYQQKCGcUTXPLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--posk.bounces.google.com X-Stat-Signature: dj4c3c7hwfwmc3ye8onmoq1nu9u9ct87 X-Rspamd-Queue-Id: 1ABC0180004 X-Rspamd-Server: rspam12 X-HE-Tag: 1642117214-48028 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: Add enum umcg_kick_flags: @UMCG_KICK_RESCHED: reschedule the task; used for worker preemption @UMCG_KICK_TTWU: wake the task; used to wake servers. It is sometimes useful to wake UMCG servers from the userspace, for example when a server detects a worker wakeup and wakes an idle server to run the newly woken worker. Signed-off-by: Peter Oskolkov --- include/uapi/linux/umcg.h | 10 ++++++++++ kernel/sched/umcg.c | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/umcg.h b/include/uapi/linux/umcg.h index 93fccb44283b..a29e5e91a251 100644 --- a/include/uapi/linux/umcg.h +++ b/include/uapi/linux/umcg.h @@ -148,4 +148,14 @@ enum umcg_ctl_flag { UMCG_CTL_WORKER = 0x10000, }; +/** + * enum umcg_kick_flag - flags to pass to sys_umcg_kick + * @UMCG_KICK_RESCHED: reschedule the task; used for worker preemption + * @UMCG_KICK_TTWU: wake the task; used to wake servers + */ +enum umcg_kick_flag { + UMCG_KICK_RESCHED = 0x001, + UMCG_KICK_TTWU = 0x002, +}; + #endif /* _UAPI_LINUX_UMCG_H */ diff --git a/kernel/sched/umcg.c b/kernel/sched/umcg.c index b85dec6b82e4..e33ec9eddc3e 100644 --- a/kernel/sched/umcg.c +++ b/kernel/sched/umcg.c @@ -669,12 +669,15 @@ SYSCALL_DEFINE2(umcg_kick, u32, flags, pid_t, tid) if (!task) return -ESRCH; - if (flags) + if (flags != UMCG_KICK_RESCHED && flags != UMCG_KICK_TTWU) return -EINVAL; #ifdef CONFIG_SMP - smp_send_reschedule(task_cpu(task)); + if (flags == UMCG_KICK_RESCHED) + smp_send_reschedule(task_cpu(task)); #endif + if (flags == UMCG_KICK_TTWU) + try_to_wake_up(task, TASK_NORMAL, 0); return 0; }