From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C16D5421EED for ; Thu, 30 Apr 2026 13:38:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777556287; cv=none; b=CXAi27m4Nqw7cisq9uNIAl+Kn2mtxikPbInNRmIVmKdQRYp0VAD8pz2+sSNoTDURcJcMD8SMTINqzdjEZcqQfXbYtIuG2Jhc+dOvxo56pys1g3LNaOCQ4nfXf89PFAGKe307QbHvx+tGA7QcaJYcnYWRKTgOojYnYENjsjfcYDU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777556287; c=relaxed/simple; bh=Wc+D8caaBVXx/76SzhM6rbIvQSOxiKy5eEeWre1Y7E4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZCmdP7O0+RT91A7vl+PzJpIpXD47XbCQq6jOj5ySDInhFnqJSl/9cHzxic8Xw8PZiYDAOtE0froNEM84x7pYsiukCFSDWI/Eq7fSCnFmZ6ihekV5t8wDUadcwzkO+Mbe5PU6fWg9LTOvpAxNWBulTC+DSwV22Ao6DA3Ul3sH75M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=S9w93TRD; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="S9w93TRD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777556283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zvpc3ouiLend2nTOGgnsZ2P9GoiNqqJrDz+MQzcNl04=; b=S9w93TRDL3xAasIqAvq6aQqzw1tGNRWBELiXsfsOFGECrFfn4wyvrwHEwmWAmnVf+iby0i nE9s/JWpkJnZW7MGgXV7N3NBHVz3LY8ypb7+u5J0uIUOKMjojhm4i5jjNcGY36kM0sEv/H oSVbj6Yu5iP40AWZTooYkNmqPCcOUmg= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-568-YL4cB2RLPz6fGQaMRyb7XA-1; Thu, 30 Apr 2026 09:37:57 -0400 X-MC-Unique: YL4cB2RLPz6fGQaMRyb7XA-1 X-Mimecast-MFC-AGG-ID: YL4cB2RLPz6fGQaMRyb7XA_1777556276 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-8abd6e281c0so31134036d6.1 for ; Thu, 30 Apr 2026 06:37:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777556276; x=1778161076; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Zvpc3ouiLend2nTOGgnsZ2P9GoiNqqJrDz+MQzcNl04=; b=PM6aT+sYTTgslrgDKbiyCILuinOufVWNhxFl7U6GLF2HcSBV7zq55S+6EUZu+968Y0 fQNoNLLajmCfbZ3u5cDOydGwriwyf3BHvpTqcaJ8u+2P8GbiDWNiHDBQN94OFl4XhQl/ Ywnqh836QKEd1gknUDGkI6eXCXkY5sTDGI564JujpV3t9A5QHlJR2KqWq07Gw1najm9r Kjo+qFdb0uAx0VWM7bozrxiCiu00eKX3X3z/JJailSsD1EDFL7vnZzCKgh3VX+vXyWzn qslPwT6HeMdefH3ZsH8t3X7+ZLyR9cThf4v4lVYa7SYi+bTjpuw2T1BnY9yxhqOqU5w1 gRoA== X-Forwarded-Encrypted: i=1; AFNElJ8QXn737hvDAR+Eedp2+8I9uptHzHBYgMXT2fofGdLW6CvXXUY5pULcyqsyBAKyiS+wacJ6HGLo03Af38M=@vger.kernel.org X-Gm-Message-State: AOJu0YyZqClaFwOke7yqPoncqnap4xTUED2YtLhuJuuZVH6Rr/5QbwBd i4fTb1LnTlySHmpzPc6twrgIL15kqdSw2hLnsHCJ9ULGf4XJ+PwOzIAWI/1Xm3/jVbUIvcxND9A hFQn49lTsK1hRLQ9qMVAb5OCQ0rrkPdZHHbjh1Iq0y4rtd27wwzycgrYr63OAPquFvA== X-Gm-Gg: AeBDies9S0HgMUdkodQh3I42YvsPIgj7bwjLHvKCvAG4HITArRwi6ffZ7yy3ouaspLm +CgJkuGRps0ksTk9xC9Q1M7VvHZALFqSExXq42jmPgHuLq8GGYH1dn0yzFL+3BL1C8wqtbYIVn1 n5ikdtHRChT6uGBCIO6diwFtVwjdUG6QDWPHmCpyxzkULcvqM0yd/MKGywEjia3TJT6zLdV3cBY y0ETM3rhF+lTDU1GDlFILBGgHq+XdzsxDjFNjMxYroHEzI7E3DQJ60yRtW7gWgSOCK/mWHVSaPb bXnJuI2/6xY288JGR2vMFBJQ0hUFp7KsoMcbbVJXghagyqv8rhXBMtz4ViV8CIMAPsfBTK10Xei 5MvlSUafYLjppb12Uj/PCwl96kuNHUz0nnS0= X-Received: by 2002:a05:622a:586:b0:509:2b02:c1bd with SMTP id d75a77b69052e-5102aad8a94mr44515901cf.12.1777556276090; Thu, 30 Apr 2026 06:37:56 -0700 (PDT) X-Received: by 2002:a05:622a:586:b0:509:2b02:c1bd with SMTP id d75a77b69052e-5102aad8a94mr44515291cf.12.1777556275587; Thu, 30 Apr 2026 06:37:55 -0700 (PDT) Received: from [192.168.2.110] ([70.53.202.134]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5101aeb58desm48316071cf.29.2026.04.30.06.37.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Apr 2026 06:37:55 -0700 (PDT) Message-ID: <6b12453b-2683-41cc-bb4c-602eda6bf9d8@redhat.com> Date: Thu, 30 Apr 2026 09:37:43 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 04/54] selftests/mm: migration: properly cleanup fork()ed processes To: Mike Rapoport , Andrew Morton , David Hildenbrand Cc: Baolin Wang , Barry Song , Dev Jain , Donet Tom , Jason Gunthorpe , John Hubbard , "Liam R. Howlett" , Lance Yang , Leon Romanovsky , Lorenzo Stoakes , Mark Brown , Michal Hocko , Nico Pache , Peter Xu , Ryan Roberts , Sarthak Sharma , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , Zi Yan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org References: <20260428204240.1924129-1-rppt@kernel.org> <20260428204240.1924129-5-rppt@kernel.org> Content-Language: en-US, en-CA From: Luiz Capitulino In-Reply-To: <20260428204240.1924129-5-rppt@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026-04-28 16:41, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > Several migration test use fork() to create worker processes. These > processes are later killed, but nothing collects their exit status and they > remain as zombies in the system. > > Add a helper function that kills the worker processes, waitpid()s for > them and verifies the exit status. > > Replace the loops that call kill() for each process with a call to that > helper. > > The addition of waitpid() calls also makes sure the migrating process never > exits before the processes accessing the memory, so it's possible to drop > the call to prctl(PR_SET_PDEATHSIG, SIGHUP). > > Reported-by: Luiz Capitulino > Signed-off-by: Mike Rapoport (Microsoft) > --- > tools/testing/selftests/mm/migration.c | 54 +++++++++++++------------- > 1 file changed, 27 insertions(+), 27 deletions(-) > > diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c > index 3630f2fb0800..76e380b74658 100644 > --- a/tools/testing/selftests/mm/migration.c > +++ b/tools/testing/selftests/mm/migration.c > @@ -67,6 +67,24 @@ FIXTURE_TEARDOWN(migration) > free(self->pids); > } > > +static bool kill_children(FIXTURE_DATA(migration) * self) > +{ > + int i, status; > + pid_t pid; > + > + for (i = 0; i < self->nthreads; i++) { > + pid = self->pids[i]; > + if (kill(pid, SIGTERM)) > + return false; > + if (pid != waitpid(pid, &status, 0)) > + return false; > + if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGTERM) > + return false; > + } Why do we stop at the first error? Wouldn't it be better to kill & collect all of them and then return false if at least one fails? > + > + return true; > +} > + > int migrate(uint64_t *ptr, int n1, int n2) > { > int ret, tmp; > @@ -160,20 +178,14 @@ TEST_F_TIMEOUT(migration, shared_anon, 2*RUNTIME) > memset(ptr, 0xde, TWOMEG); > for (i = 0; i < self->nthreads; i++) { > pid = fork(); > - if (!pid) { > - prctl(PR_SET_PDEATHSIG, SIGHUP); > - /* Parent may have died before prctl so check now. */ > - if (getppid() == 1) > - kill(getpid(), SIGHUP); This goes beyond this series, but I wonder if we should have this check in access_mem() in case the parent dies in migrate(). > + if (!pid) > access_mem(ptr); > - } else { > + else > self->pids[i] = pid; > - } > } > > ASSERT_EQ(migrate(ptr, self->n1, self->n2), 0); > - for (i = 0; i < self->nthreads; i++) > - ASSERT_EQ(kill(self->pids[i], SIGTERM), 0); > + ASSERT_EQ(kill_children(self), true); > } > > /* > @@ -236,20 +248,14 @@ TEST_F_TIMEOUT(migration, shared_anon_thp, 2*RUNTIME) > memset(ptr, 0xde, pmdsize); > for (i = 0; i < self->nthreads; i++) { > pid = fork(); > - if (!pid) { > - prctl(PR_SET_PDEATHSIG, SIGHUP); > - /* Parent may have died before prctl so check now. */ > - if (getppid() == 1) > - kill(getpid(), SIGHUP); > + if (!pid) > access_mem(ptr); > - } else { > + else > self->pids[i] = pid; > - } > } > > ASSERT_EQ(migrate(ptr, self->n1, self->n2), 0); > - for (i = 0; i < self->nthreads; i++) > - ASSERT_EQ(kill(self->pids[i], SIGTERM), 0); > + ASSERT_EQ(kill_children(self), true); > } > > /* > @@ -300,20 +306,14 @@ TEST_F_TIMEOUT(migration, shared_anon_htlb, 2*RUNTIME) > memset(ptr, 0xde, hugepage_size); > for (i = 0; i < self->nthreads; i++) { > pid = fork(); > - if (!pid) { > - prctl(PR_SET_PDEATHSIG, SIGHUP); > - /* Parent may have died before prctl so check now. */ > - if (getppid() == 1) > - kill(getpid(), SIGHUP); > + if (!pid) > access_mem(ptr); > - } else { > + else > self->pids[i] = pid; > - } > } > > ASSERT_EQ(migrate(ptr, self->n1, self->n2), 0); > - for (i = 0; i < self->nthreads; i++) > - ASSERT_EQ(kill(self->pids[i], SIGTERM), 0); > + ASSERT_EQ(kill_children(self), true); > } > > TEST_HARNESS_MAIN