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.129.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 B300742EEDD for ; Thu, 30 Apr 2026 14:54:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777560871; cv=none; b=BXOIa9WOnjO8DmvSC5sVk2zn6QJeEPsPP39kjwskIJLLdlGK5NWQEb4t6HmeRdXQ1EQ40BopCCF2BQvXx1ek/v9CtWV3IkUJ66yKrsXNl2clOPS8bbXfoQJnpKnxGBGGoDSGGBM3ed5ABv5al56Nev9xbeLzGl3YCvSNRpp8yow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777560871; c=relaxed/simple; bh=LM7zZ3BKn/6jhx52cjuHs4HlBrG0AdmbYZ63UH8/riE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kuH8ksG7VCPJibOx4aySwyktZW580PmrVmXZo16xbXCPQurqH7MacnG4saR3YelHdF3i+WfAm/hCMJ+KkW0O4FuZe4vACjcnb6ISlHi7Vo8IdAaw0wYxSO6BW7PjHFbF/eMhVlBUQCzKM6VRTdTGQO+ymonie9HcfMJFd1+04Jw= 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=NgN5YxiO; arc=none smtp.client-ip=170.10.129.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="NgN5YxiO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777560869; 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=7p5fXb8rzgGRGsySMmX1Wn2cmLsL9wBpLlARqjRpNoc=; b=NgN5YxiOVR8C3i6HVjymiYUJqskMzcbhLT5fyKCBemGTnHzoG6eT8fjsKRg9prnQzE4Ga1 mQ/PF6nfT5Y0b+uje/KsN/5n+Pc3VIa8aSukBjLKkXW+R7ldIxdJQf6plzfJmDZ/Lix6q6 p6+48gja5EVzFnztUMvxjE8+mGH2CoY= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-257-90HeYWn9OKuLSWKxkNochA-1; Thu, 30 Apr 2026 10:54:27 -0400 X-MC-Unique: 90HeYWn9OKuLSWKxkNochA-1 X-Mimecast-MFC-AGG-ID: 90HeYWn9OKuLSWKxkNochA_1777560867 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-8b4bebd2b2aso5621186d6.1 for ; Thu, 30 Apr 2026 07:54:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777560867; x=1778165667; 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=7p5fXb8rzgGRGsySMmX1Wn2cmLsL9wBpLlARqjRpNoc=; b=M2RXU4YbRVY5DcSBtRH08zcSwiXueDU+YACuMbfBllBBfBSmGxFiG2n8kk+MVXdT9s zQivYT/jzBitLpvWtv6VgkLOWaqgqWdsFK8fEPzijGlIaOEyehWTXIXJO3mqhR9ETjGz Yg+RIWRx06leMjzpJaJjD5I4B4ZEn8q6RjwDPfqC6v5ztvmP+r181Xhbd18jO5xMQCGc Fw3od4DtfWrY+pTFMu+oDbvDe3WV4pS0HKMcDd7e2OhD+YHMhvoiXGEE4NcD+/AFMC2A nvmTGcct+5tU73GXjAUu9VAuj0lz0FY2TcQ5FP1/vrp6LoQ+in9Y/Hx9UFV6AG4UMBJs o2nQ== X-Forwarded-Encrypted: i=1; AFNElJ/IrDsemQfZQUXlvIRg9cSMf6nkkdGagXtf6Qq8uihu5/eMt9JZ2/nJ+fumc0Auzt22Ou8wXp+VfCZwUko=@vger.kernel.org X-Gm-Message-State: AOJu0YysKnyP0zZb0yXV+9Wm31IzreG6YMgBI7j6QXsOt5ElJ1pdPSLM aMghrOwstrjoTTkCLb5MxYTxjLo/8jN/B1XkcpmM46MGndx8X2ck6duUCp+PzlBTudQLrJB9yut 7JyfSKxbm+AV12rlkubOLSzmoWrNs8/jiQEXLpCsSvTomnJ4N1LFNF0tGhJdzG2uCvA== X-Gm-Gg: AeBDieu6z50SpozduGMKsstSAnMyCRhTuTjR2OPOZzrLyXqwWU6ME0cJd6bZmYklvD+ Wmuu4n2n98EBq8taGwDOby66Il71USJcJ2eL0+2NeORNXirHFh/IA1SAlPfInlizhvBx8pXtHIG UTpBFWut71lcJ07PTSBzKysPLxWPl1lOhFFUWwtvwMiEtlNcn+cAbmMvF1IYfyo3VRtYq+6EHGX 89c+c8ckz+t5ELJHHSqK0bpn/YFd5akZcn9h2QAfO/fxS+sg12oQPpOVz0wJIrZRNWoJaKaUI76 v/YDhow5fuRw6IwoQeOP8N0ZLu6xVxOV4RS4qyRUffWgY/+VLAXB+SCxnxZ8Uj6nHghSU9Xd/Pv +IKdutkzs06t8ep9m2Ssu10m7/mnmWKmYGNc= X-Received: by 2002:a05:6214:5549:b0:89c:4b37:7106 with SMTP id 6a1803df08f44-8b4000f7fdbmr35628756d6.34.1777560866854; Thu, 30 Apr 2026 07:54:26 -0700 (PDT) X-Received: by 2002:a05:6214:5549:b0:89c:4b37:7106 with SMTP id 6a1803df08f44-8b4000f7fdbmr35628096d6.34.1777560866347; Thu, 30 Apr 2026 07:54:26 -0700 (PDT) Received: from [192.168.2.110] ([70.53.202.134]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b3ff439c2csm19482476d6.23.2026.04.30.07.54.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Apr 2026 07:54:25 -0700 (PDT) Message-ID: <6f8de9a3-2adc-4d96-bc0e-5171bcbba60f@redhat.com> Date: Thu, 30 Apr 2026 10:54:14 -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 Cc: Andrew Morton , David Hildenbrand , 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> <6b12453b-2683-41cc-bb4c-602eda6bf9d8@redhat.com> Content-Language: en-US, en-CA From: Luiz Capitulino In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026-04-30 10:40, Mike Rapoport wrote: > On Thu, Apr 30, 2026 at 09:37:43AM -0400, Luiz Capitulino wrote: >> 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? > > Yep, makes sense. > >>> + >>> + 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(). > > With added kill() + waitpid() this should not happen. I was thinking in the case of a crash, but looking at it again it seems to be impossible so it's fine.