Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp12289imm; Tue, 10 Jul 2018 19:47:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc5A9SCEnbDCUKKAsCJ0ZyT9gG9qqmfkhlKSDWiEcu1OOUT9UmtZr4ltUFIHrr5cBeOI3NZ X-Received: by 2002:a17:902:1025:: with SMTP id b34-v6mr26511865pla.112.1531277248385; Tue, 10 Jul 2018 19:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531277248; cv=none; d=google.com; s=arc-20160816; b=qVUIWNZWZ1EcFMThkSGKUoe/aofqYhvkbK5FWqF9m5Th5DpXaEcn1LPKeIkenNhO6s AQGdM0xZmP189eDzw4n6Re8F7k/GdMRXnieevfGRvJx+T5chhh6M6/95rym9qhw/6rp9 +Mfi9JafrAecbNowhAFniZuJ9NmLzj20s9vVzsbOtuuzg4WrwtmbCEmmx/crA2E+kDlU r2Gx6YvG2Pc1ebk8uI4LrlMH3hJpnu68LjbTe9UArWN2+E0wkulATuj/pRGAd/nkYVbl Yheh/ZdRv4ZZ2Ej86PevsUDLBmrlGJZKt2f3R37VHjNgFtNCOwHNocrRsheI8cIE6PSA LbRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=SvgbsW/QpITeLthmokZuhP+H1nqP5tTdJQ1sr8HzZJs=; b=uJaDpxxhaLr2r6Ih5PCEfzjD9k/1ybtQ33Z+SMGFA+dDGUZEP61+dmr1YaWtJU90p3 4kjf1YjKUCW1pROjhsPhEIrsMiQdK8oe4WhMRSWy/YOMvt0tgrngT4N40Dwsp/5cmXEm kbBR+lHWM+GwsbB1Xa4LfkQb/iEqGYTkqoEk+3dTCES/8n1UnjO3am4fTodfn4XJwkUU +q9HxcAd/q2ITXz6a0L8ESn/g8mNmzVDHXUJRu1Elp5Tr/JL1DqJA3cKRlYSNQ87uywo eG2G7duIKG0RjdFEQOahK9+ZTLN4UG//F4Bz1hXv5RajQLC4ZTq7Blihw8Zos+z0aNrV zpjw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3-v6si18262981plt.71.2018.07.10.19.47.13; Tue, 10 Jul 2018 19:47:28 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732499AbeGKCsR (ORCPT + 99 others); Tue, 10 Jul 2018 22:48:17 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:40143 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732292AbeGKCsQ (ORCPT ); Tue, 10 Jul 2018 22:48:16 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fd58w-00012n-S2; Tue, 10 Jul 2018 20:46:14 -0600 Received: from [97.119.167.31] (helo=x220.int.ebiederm.org) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fd58u-00063R-C8; Tue, 10 Jul 2018 20:46:14 -0600 From: "Eric W. Biederman" To: Linus Torvalds Cc: Oleg Nesterov , Andrew Morton , linux-kernel@vger.kernel.org, Wen Yang , majiang , "Eric W. Biederman" Date: Tue, 10 Jul 2018 21:44:51 -0500 Message-Id: <20180711024459.10654-3-ebiederm@xmission.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <877em2jxyr.fsf_-_@xmission.com> References: <877em2jxyr.fsf_-_@xmission.com> X-XM-SPF: eid=1fd58u-00063R-C8;;;mid=<20180711024459.10654-3-ebiederm@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.119.167.31;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18xj147MAApgUOZorZ8UDBzmMGhEuNS+SE= X-SA-Exim-Connect-IP: 97.119.167.31 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sa02.xmission.com X-Spam-Level: **** X-Spam-Status: No, score=4.7 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,LotsOfNums_01,TR_Symld_Words,T_TooManySym_01, T_TooManySym_02,T_TooManySym_03,XMNoVowels,XMSubLong autolearn=disabled version=3.4.0 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 1.5 TR_Symld_Words too many words that have symbols inside * 1.5 XMNoVowels Alpha-numberic number with no vowels * 1.2 LotsOfNums_01 BODY: Lots of long strings of numbers * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa02 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_02 5+ unique symbols in subject * 0.0 T_TooManySym_03 6+ unique symbols in subject * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa02 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ****;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 2048 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 2.9 (0.1%), b_tie_ro: 1.95 (0.1%), parse: 1.40 (0.1%), extract_message_metadata: 29 (1.4%), get_uri_detail_list: 6 (0.3%), tests_pri_-1000: 11 (0.5%), tests_pri_-950: 2.3 (0.1%), tests_pri_-900: 1.83 (0.1%), tests_pri_-400: 48 (2.3%), check_bayes: 45 (2.2%), b_tokenize: 22 (1.1%), b_tok_get_all: 10 (0.5%), b_comp_prob: 5 (0.2%), b_tok_touch_all: 5 (0.3%), b_finish: 0.81 (0.0%), tests_pri_0: 1937 (94.6%), check_dkim_signature: 0.96 (0.0%), check_dkim_adsp: 5 (0.3%), tests_pri_500: 9 (0.4%), rewrite_mail: 0.00 (0.0%) Subject: [RFC][PATCH 03/11] pids: Compute task_tgid using signal->leader_pid X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cost is the the same and this removes the need to worry about complications that come from de_thread and group_leader changing. __task_pid_nr_ns has been updated to take advantage of this change. Signed-off-by: "Eric W. Biederman" --- arch/ia64/kernel/asm-offsets.c | 2 +- arch/ia64/kernel/fsys.S | 8 ++++---- drivers/platform/x86/thinkpad_acpi.c | 1 + fs/fuse/file.c | 1 + fs/notify/fanotify/fanotify.c | 1 + include/linux/sched.h | 5 ----- include/linux/sched/signal.h | 5 +++++ include/net/scm.h | 1 + kernel/pid.c | 15 ++++++++------- 9 files changed, 22 insertions(+), 17 deletions(-) diff --git a/arch/ia64/kernel/asm-offsets.c b/arch/ia64/kernel/asm-offsets.c index f4db2168d1b8..f5433bb7f04a 100644 --- a/arch/ia64/kernel/asm-offsets.c +++ b/arch/ia64/kernel/asm-offsets.c @@ -50,7 +50,6 @@ void foo(void) DEFINE(IA64_TASK_BLOCKED_OFFSET,offsetof (struct task_struct, blocked)); DEFINE(IA64_TASK_CLEAR_CHILD_TID_OFFSET,offsetof (struct task_struct, clear_child_tid)); - DEFINE(IA64_TASK_GROUP_LEADER_OFFSET, offsetof (struct task_struct, group_leader)); DEFINE(IA64_TASK_TGIDLINK_OFFSET, offsetof (struct task_struct, pids[PIDTYPE_PID].pid)); DEFINE(IA64_PID_LEVEL_OFFSET, offsetof (struct pid, level)); DEFINE(IA64_PID_UPID_OFFSET, offsetof (struct pid, numbers[0])); @@ -68,6 +67,7 @@ void foo(void) DEFINE(IA64_SIGNAL_GROUP_STOP_COUNT_OFFSET,offsetof (struct signal_struct, group_stop_count)); DEFINE(IA64_SIGNAL_SHARED_PENDING_OFFSET,offsetof (struct signal_struct, shared_pending)); + DEFINE(IA64_SIGNAL_LEADER_PID_OFFSET, offsetof (struct signal_struct, leader_pid)); BLANK(); diff --git a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S index fe742ffafc7a..eaf5a0d6f3e0 100644 --- a/arch/ia64/kernel/fsys.S +++ b/arch/ia64/kernel/fsys.S @@ -62,16 +62,16 @@ ENTRY(fsys_getpid) .prologue .altrp b6 .body - add r17=IA64_TASK_GROUP_LEADER_OFFSET,r16 + add r17=IA64_TASK_SIGNAL_OFFSET,r16 ;; - ld8 r17=[r17] // r17 = current->group_leader + ld8 r17=[r17] // r17 = current->signal add r9=TI_FLAGS+IA64_TASK_SIZE,r16 ;; ld4 r9=[r9] - add r17=IA64_TASK_TGIDLINK_OFFSET,r17 + add r17=IA64_SIGNAL_LEADER_PID_OFFSET,r17 ;; and r9=TIF_ALLWORK_MASK,r9 - ld8 r17=[r17] // r17 = current->group_leader->pids[PIDTYPE_PID].pid + ld8 r17=[r17] // r17 = current->signal->leader_pid ;; add r8=IA64_PID_LEVEL_OFFSET,r17 ;; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index cae9b0595692..d556e95c532c 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/fuse/file.c b/fs/fuse/file.c index a201fb0ac64f..b00a3f126a89 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index f90842efea13..6e828cb82e5e 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/include/linux/sched.h b/include/linux/sched.h index 87bf02d93a27..a461ff89a3af 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1202,11 +1202,6 @@ static inline struct pid *task_pid(struct task_struct *task) return task->pids[PIDTYPE_PID].pid; } -static inline struct pid *task_tgid(struct task_struct *task) -{ - return task->group_leader->pids[PIDTYPE_PID].pid; -} - /* * Without tasklist or RCU lock it is not safe to dereference * the result of task_pgrp/task_session even if task == current, diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index d8ef0a3d2e7e..b95a272c1ab5 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -564,6 +564,11 @@ struct pid *task_pid_type(struct task_struct *task, enum pid_type type) return task->pids[type].pid; } +static inline struct pid *task_tgid(struct task_struct *task) +{ + return task->signal->leader_pid; +} + static inline int get_nr_threads(struct task_struct *tsk) { return tsk->signal->nr_threads; diff --git a/include/net/scm.h b/include/net/scm.h index 903771c8d4e3..1ce365f4c256 100644 --- a/include/net/scm.h +++ b/include/net/scm.h @@ -8,6 +8,7 @@ #include #include #include +#include /* Well, we should have at least one descriptor open * to accept passed FDs 8) diff --git a/kernel/pid.c b/kernel/pid.c index 157fe4b19971..d0de2b59f86f 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -421,13 +421,14 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type, if (!ns) ns = task_active_pid_ns(current); if (likely(pid_alive(task))) { - if (type != PIDTYPE_PID) { - if (type == __PIDTYPE_TGID) - type = PIDTYPE_PID; - - task = task->group_leader; - } - nr = pid_nr_ns(rcu_dereference(task->pids[type].pid), ns); + struct pid *pid; + if (type == PIDTYPE_PID) + pid = task_pid(task); + else if (type == __PIDTYPE_TGID) + pid = task_tgid(task); + else + pid = rcu_dereference(task->group_leader->pids[type].pid); + nr = pid_nr_ns(pid, ns); } rcu_read_unlock(); -- 2.17.1