From mboxrd@z Thu Jan 1 00:00:00 1970 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 873D0C02192 for ; Wed, 5 Feb 2025 20:34:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F8066B0088; Wed, 5 Feb 2025 15:34:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A8996B0089; Wed, 5 Feb 2025 15:34:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E631A6B0093; Wed, 5 Feb 2025 15:34:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C10C46B0088 for ; Wed, 5 Feb 2025 15:34:33 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6F43A80B05 for ; Wed, 5 Feb 2025 20:34:33 +0000 (UTC) X-FDA: 83087044026.22.91EC6D6 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by imf17.hostedemail.com (Postfix) with ESMTP id 8284340011 for ; Wed, 5 Feb 2025 20:34:31 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=LSqzuvFt; spf=pass (imf17.hostedemail.com: domain of mjguzik@gmail.com designates 209.85.208.42 as permitted sender) smtp.mailfrom=mjguzik@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738787671; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6OMz7JDebVsaDEFB8And8TQUKXqKBE8TARUzFCBMADY=; b=4ygoZkhYmw44Z/50YO0KJFnFSzwQacqh0M4IkbSTKO9nR1wzhHtCEbzDbN9xKNKnmKhYo1 mbhtenHoTABpeBOi2sxnrms3/Px4DICWrb82GTlVHgnTU0ZJw0mxtWJaBoTfkyRw9rybk0 pA00H25oYjaevf4vfW+AHpybtMPurrA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=LSqzuvFt; spf=pass (imf17.hostedemail.com: domain of mjguzik@gmail.com designates 209.85.208.42 as permitted sender) smtp.mailfrom=mjguzik@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738787671; a=rsa-sha256; cv=none; b=obLjlK7vj5A/wlbWQog4KMJuouGNuRoo+3h5io9XGprGWYkttHdgAEx0+H2J7C1UV6nPhx v9zUfm/dDfRULQP7Ig5X8f+RI8pmw7OncY04TD+Fie6Xfsf/gmGfJ0PJPcBff9f6IFjRNd DMQg7seDry+jG3oCJk33E8EOVJ4CvjU= Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5dce27a72e8so452758a12.2 for ; Wed, 05 Feb 2025 12:34:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738787670; x=1739392470; darn=kvack.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6OMz7JDebVsaDEFB8And8TQUKXqKBE8TARUzFCBMADY=; b=LSqzuvFtC6588Kr4Mke0K1/2b/xEsR+9w1/BpLkP9Aro/9zXMviyOO+cpY+18dWNmj H0B5wRwOJYZpXSzUtgw9aJUeTqvHlUBqZsMCwcOnrrIn+3N6qs+YbuBFdhxAjFITtDHu 5sAK/EDEeKCha9FByYirOgKfSx9E9vEF4h/q0uw3BF/eYp4ovABzMoc7+7mSq/7i8HjZ t/bKKJgvcV7+9E6VxWQVe+0f2w4gFF7OFSZXLg/YC13r67fizcBINUH+xVvZOfWY+N+s bz/e0491MksmMTKxoTOuSwij8olSnR9JwMS74TLTsHBXLi8d/sPJy8XZE6JTA0KlUClo uTZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738787670; x=1739392470; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6OMz7JDebVsaDEFB8And8TQUKXqKBE8TARUzFCBMADY=; b=rBjFaptUcZ0ddAwUxe4t3ny16J9nQy13pzpR3cyzo0iIYzphJnvJvRUx1R6diBV9LZ v32nrqaGxgRIaKSS9mtQ7RQYfzjf7o8rfoFQylkFekRinlEKDd9tmBiPPyi3bJ00JZWj cTd0aLh7HEg7tGbf/EgBwGjQRNfFXssa89zx+oQXK0IG2Yig2Gw6LcuBU6bXNOC1iGqE FkEVpeJqJJ7HNYhP+OVaM5+YPYhNf9AWmAngst3y0dJHyPHkfUQUnqshi4zVmZauvY1+ dGzEAIxrc43F3b5BXKDEOi2vDtkrhrY/rbXm8mFE3S/yaC434eMlOWDCNGWjBauxhF3/ KUbQ== X-Forwarded-Encrypted: i=1; AJvYcCUad+9iNzCjdUIkCOCzFZB346ajcmWPXy+VwGIoT+NILxDegXA47/nivoRmhsy4WSeCeFQE+bbPQw==@kvack.org X-Gm-Message-State: AOJu0YzRD71OA6wAR3hnjtNjXCLFmDEn6DWGdVbGJ0RY23xPK3w0zGVV ALI9um5b9v/diLxYclloo3h6NCunU0x98S2nhWKvrdkBOEV1shb+dOQcwtytROhrGMAqjvT/0TL vyEB3s9srhOjqlMvbxIuF5hZ12+U= X-Gm-Gg: ASbGnctsnKGp98/w8r1k+TvyO5Zfkg4DJH2G/PucMFE6sr0jtQgG+FLQzTjMfilehoK LuIlk/sD0y17SZxUKmyBFnvTGXABVxnxKI/dtAqJn742nCf0psk/F3SSavyCHMJuR8NhUsfU= X-Google-Smtp-Source: AGHT+IFwmUdMIWWKf38XVdsaxQLtbeeO1zD+lKAcNS7molklTDJuLyO8/LrFcBnfgs38/0v3rBafeSC7o4eyEZzzbPQ= X-Received: by 2002:a05:6402:845:b0:5d3:e766:6143 with SMTP id 4fb4d7f45d1cf-5dcdb77fba0mr5108263a12.30.1738787669759; Wed, 05 Feb 2025 12:34:29 -0800 (PST) MIME-Version: 1.0 References: <20250205193221.402150-1-mjguzik@gmail.com> <20250205193221.402150-4-mjguzik@gmail.com> In-Reply-To: From: Mateusz Guzik Date: Wed, 5 Feb 2025 21:34:18 +0100 X-Gm-Features: AWEUYZl6IU4tuGZOtiYDvVaB9yI0LX9EP_anNTFZMZfOekz1ZBbVGZRdcXKdTGk Message-ID: Subject: Re: [PATCH v4 3/5] pid: sprinkle tasklist_lock asserts To: "Liam R. Howlett" , Mateusz Guzik , ebiederm@xmission.com, oleg@redhat.com, brauner@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 8284340011 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 5sto16mn97y9iakthbr68ye7s6mcayr3 X-HE-Tag: 1738787671-49136 X-HE-Meta: U2FsdGVkX1+5ZYKUcLipn5tHpaUnI5sspn+KQp/ggdLPjI5bSY3oNJu9HTjgT4TkqQMDBfoA26K0uaojDjBlIonWPWdWbXiEvlh6UXeri680bUhHFABbEfgQqZN3955vR1753x2KxkwFccBAYfNDz8oidPE12HJjGs2Wm7dA5bEgrO+/vIe+Sz51YByV1d2URBpbyZ/W5B8cb5hM6iPO75B+BYdEHDsPCBUJg1dCJ4+/vOJEs3gECY6VDa4+xWM1ULe73zIY1HLoHLd1ZYf1bJmJu3qkcw4s3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VCv50zSFG0tmbej9kgILhJKcpsBW0Wquv6+L03pYV+jgOUlDsFZhabIMi2uDSnLLbBAl56eZ+5ttaJ6jWtRtyHn5H6qLrC4dhrP6Lq8gK5wthCtiXFRqv7IHq4H3QqDtLkSFmR4FATTVhEjmrXNkK+xpPcIJbmucNTVc3ZKJ1T5puyryF9/JW9RA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000100, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Feb 5, 2025 at 9:27=E2=80=AFPM Liam R. Howlett wrote: > > * Mateusz Guzik [250205 14:33]: > > If a patch is worth doing, it's worth explaining. I'm surprised you > didn't add a comment after the last revision missed a comment on patch > 2/6. This is literally in the submitting patches document [1]. > > I don't mean to delay this series, but I do want to know why things are > done when I'm hunting through git logs. Having a change log isn't > optional, and now you know that Andrews script won't fix this problem > [2]. > > I see you are upset by this considering the terse and lack of > punctuation in patch 2, but please try to understand these comments > serve a purpose in maintaining the code years later. > I'm not upset. For this specific case I don't know what can be written in the body given the really self-explanatory nature of the change, other than to spell it out(?). Does this work for you: The routines need to be called with the tasklist_lock, the asserts validate at runtime that this holds. I also git log a lot and like to know what's up, to that end I appreciate *short* commit messages so that I know there is nothing more to the patch than meets the eye. In particular if there is nothing of value to add in the body, I appreciate if there is none. But that's me, I'm not going to insist one way or the other. > [1]. https://www.kernel.org/doc/html/v6.12/process/submitting-patches.htm= l#describe-your-changes > [2]. https://lore.kernel.org/all/20250203175128.80319b42c9739f0d420080a4@= linux-foundation.org/ > > > Reviewed-by: Oleg Nesterov > > Signed-off-by: Mateusz Guzik > > --- > > kernel/pid.c | 15 ++++++++++++--- > > 1 file changed, 12 insertions(+), 3 deletions(-) > > > > diff --git a/kernel/pid.c b/kernel/pid.c > > index 924084713be8..2ae872f689a7 100644 > > --- a/kernel/pid.c > > +++ b/kernel/pid.c > > @@ -339,17 +339,23 @@ static struct pid **task_pid_ptr(struct task_stru= ct *task, enum pid_type type) > > */ > > void attach_pid(struct task_struct *task, enum pid_type type) > > { > > - struct pid *pid =3D *task_pid_ptr(task, type); > > + struct pid *pid; > > + > > + lockdep_assert_held_write(&tasklist_lock); > > + > > + pid =3D *task_pid_ptr(task, type); > > hlist_add_head_rcu(&task->pid_links[type], &pid->tasks[type]); > > } > > > > static void __change_pid(struct task_struct *task, enum pid_type type, > > struct pid *new) > > { > > - struct pid **pid_ptr =3D task_pid_ptr(task, type); > > - struct pid *pid; > > + struct pid **pid_ptr, *pid; > > int tmp; > > > > + lockdep_assert_held_write(&tasklist_lock); > > + > > + pid_ptr =3D task_pid_ptr(task, type); > > pid =3D *pid_ptr; > > > > hlist_del_rcu(&task->pid_links[type]); > > @@ -386,6 +392,8 @@ void exchange_tids(struct task_struct *left, struct= task_struct *right) > > struct hlist_head *head1 =3D &pid1->tasks[PIDTYPE_PID]; > > struct hlist_head *head2 =3D &pid2->tasks[PIDTYPE_PID]; > > > > + lockdep_assert_held_write(&tasklist_lock); > > + > > /* Swap the single entry tid lists */ > > hlists_swap_heads_rcu(head1, head2); > > > > @@ -403,6 +411,7 @@ void transfer_pid(struct task_struct *old, struct t= ask_struct *new, > > enum pid_type type) > > { > > WARN_ON_ONCE(type =3D=3D PIDTYPE_PID); > > + lockdep_assert_held_write(&tasklist_lock); > > hlist_replace_rcu(&old->pid_links[type], &new->pid_links[type]); > > } > > > > -- > > 2.43.0 > > > > --=20 Mateusz Guzik