Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp592837pxf; Thu, 25 Mar 2021 09:45:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHl85ChV52Fs8j01P2+s5DPR7dMUlpyaP8VfzCVMFdlL2VRFGvNKqons+rm9CuaHCOuRaf X-Received: by 2002:aa7:c1d5:: with SMTP id d21mr9878737edp.167.1616690741971; Thu, 25 Mar 2021 09:45:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616690741; cv=none; d=google.com; s=arc-20160816; b=ewjs+I9j7CRy6as8+PXBugDRYT01iU+cxwnfu+ISySX6g+go+yt/jjLpWWRNhIHA3G OknB3r2Z8Sf/Oiwp9Ah8qaK+OxWJehrQP81ANrWH374uyla3ICnr/+6RKWJQkRlK4oAN 8lx3C8wqMO+Tuxa3SPfMpl1aUj/V1flNKOz7I5LuHWjknN0soy7rzxem4BkEprR+sCUW wUTLBs16vbiEMVW/dnpieg5filg8gLgifY3Vz9GabMmFcVfCPbaljeWKNbsM+5sXvKbe redAIwYSZooNSqOY2G+2UlWQkUMoFtTivvWcAuF0DsYva2OW19k2IDbRtLCJ5bbi2KQp /86g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Zelrk36zpmC+2fEIaTzCe8iAs0QYE8m4zqDOwegDXxU=; b=gvOW/fH8gr/3dpCuxC3qmscWo2D3POt+ZMl0BEGxKCpzRTfIMtg+q9IiXjJ5qFHOEV rJDmDEWSBsrlpMh6ztcJ8reEp8eAzkG8fZEriR17RfTP91/GhW+ivjZbbbACbW9hLz8n lPQNpAIQ6+ICTqh3TKZQkLs1E8kh46kjEogvD7sV1XSCqB/mArfcpfFIOkVBjrPS2zKu EpRZVA4OQdlq31aEEYHaGhI7UHPnI2NaghlpzlWfrio392KYDxw+7kIdLccMs0Sf6Rvq 6a6bXre6nkgc287a69xy6DrnlOWrLWfOqNBeKr8qYB9J1/p8JTuZucEbi+Ur1GjBvNRF uJXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=QLqByaEH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id et19si4725521ejc.77.2021.03.25.09.45.18; Thu, 25 Mar 2021 09:45:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=QLqByaEH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229890AbhCYQoK (ORCPT + 99 others); Thu, 25 Mar 2021 12:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbhCYQnt (ORCPT ); Thu, 25 Mar 2021 12:43:49 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3865C06174A for ; Thu, 25 Mar 2021 09:43:49 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id z136so2520904iof.10 for ; Thu, 25 Mar 2021 09:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zelrk36zpmC+2fEIaTzCe8iAs0QYE8m4zqDOwegDXxU=; b=QLqByaEHTRPwGeUS1pOq5E8tTBozcYgNoU0DBDvnF2zaT4Moftc+JhKY6s7sagWObm pQuhuSWdD53SqSqWiQ60vUU+WrpJwTOLrbdnSAOrv5FHd1mf8yi8JX0S//j4bZxzhlKR qt1E1tR5X1rsX31PtU4jNGpbucp+ruUSzfDwXIXyCwHi4MNqLoK6shp9KlsyA429DdMW kpnB/Y4xtQp39aO8MK36jUB27WAfnrN6XfftZCG1cEb/pGnaLwgTFRMjrBtXXvyRrbRI uHc6sPcSmCOmCTU0OtWuynAM15qkhs2Dr68y+h07fTmhtexCh63eoQT7dhmOZWz96LnE 4tnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zelrk36zpmC+2fEIaTzCe8iAs0QYE8m4zqDOwegDXxU=; b=KVBQTCJ5HiyA43J11u5MZpskgCWqsqU7g4wxks+svEaQd5Kd54R5KTBcc89JeWz3aJ nVmAglpqcZJ4D1s8EQHOhgYF/ZxK874dRz0NEePTUlR8CkUDjJLNx4WsuMpo0H96mQlu Yw3bUs0QxEf3Ctnr0C/wd/cqnVdEE7ZTiR+WjKQvoCFGF9etfBZ5oC+Yry6QUkGdRcw9 kwALywu58ZtxB/OP1ef56bWZTO3cZLvnkQHumpZeDfK+8FGoMKx+9U3QqqIQKS1g3cm1 GkOz5KgB2JXpK/Qj9PALsmqSohEWza8pRhgB8IGxhj5RgApjnP5hWZ1D7SPeVR+42298 h8sA== X-Gm-Message-State: AOAM532NqfNDTdKcf1faP45KnSlLhtc9TqAyXh+Keyio42Y/HaFC6JSM 0MyJCbXTvdRnyxoz971Y6R0kSJLs+jAnkg== X-Received: by 2002:a02:714f:: with SMTP id n15mr8440902jaf.6.1616690629100; Thu, 25 Mar 2021 09:43:49 -0700 (PDT) Received: from p1.localdomain ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id k12sm2990605ios.2.2021.03.25.09.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 09:43:48 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: torvalds@linux-foundation.org, ebiederm@xmission.com, linux-kernel@vger.kernel.org, oleg@redhat.com, metze@samba.org, Jens Axboe Subject: [PATCH 1/2] kernel: don't include PF_IO_WORKERs as part of same_thread_group() Date: Thu, 25 Mar 2021 10:43:42 -0600 Message-Id: <20210325164343.807498-2-axboe@kernel.dk> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210325164343.807498-1-axboe@kernel.dk> References: <20210325164343.807498-1-axboe@kernel.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Don't pretend that the IO threads are in the same thread group, the only case where that seems to be desired is for accounting purposes. Add a special accounting function for that and make the scheduler side use it. For signals and ptrace, we don't allow them to be treated as threads anyway. Reported-by: Stefan Metzmacher Signed-off-by: Jens Axboe --- include/linux/sched/signal.h | 9 ++++++++- kernel/sched/cputime.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 3f6a0fcaa10c..4f621e386abf 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -668,11 +668,18 @@ static inline bool thread_group_leader(struct task_struct *p) } static inline -bool same_thread_group(struct task_struct *p1, struct task_struct *p2) +bool same_thread_group_account(struct task_struct *p1, struct task_struct *p2) { return p1->signal == p2->signal; } +static inline +bool same_thread_group(struct task_struct *p1, struct task_struct *p2) +{ + return same_thread_group_account(p1, p2) && + !((p1->flags | p2->flags) & PF_IO_WORKER); +} + static inline struct task_struct *next_thread(const struct task_struct *p) { return list_entry_rcu(p->thread_group.next, diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 5f611658eeab..625110cacc2a 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -307,7 +307,7 @@ void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times) * those pending times and rely only on values updated on tick or * other scheduler action. */ - if (same_thread_group(current, tsk)) + if (same_thread_group_account(current, tsk)) (void) task_sched_runtime(current); rcu_read_lock(); -- 2.31.0