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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38A3EC433F5 for ; Wed, 15 Dec 2021 18:27:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343786AbhLOS1u (ORCPT ); Wed, 15 Dec 2021 13:27:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbhLOS1s (ORCPT ); Wed, 15 Dec 2021 13:27:48 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F1D4C061574; Wed, 15 Dec 2021 10:27:48 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id t26so3420499wrb.4; Wed, 15 Dec 2021 10:27:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=H2yw4CxLWWiIu+RlENTNUgfNQZOv9uZwwB7smlx2LRE=; b=o+7iYHYe/KaKO7VigWAHSzhdOSt0x+gm0lRTk0Y4pthcUHqJTAhfRgdT3YdPrxNHu5 ebc1lhgQQHmg9yakDjDqj2GUcvidZjuW+hm7qduffFFNDkQPJiBLj1LGH01ljRVPU+qw tMebbX8AX0igX0pWUjKM/IwbzSQ5zGWfCrrf2xHcZobvgNfLuVG+ZsNUq+2i+3quRRT3 JzT+8aYqK5aNQYmeZW1YuLDg1bu3TqMHnOcgYuuCUjMlF9UY6s3hILzzlZYBcobi1ylN D2VeFt7bCgWT8PJLtufZYkARDLXOGBZkF/uGlmIZupDFvUZdY9t1hdRTc3oPX5XXT+Be qSWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=H2yw4CxLWWiIu+RlENTNUgfNQZOv9uZwwB7smlx2LRE=; b=Z0TgWD7lqS0YrS7xe0KtEo9/gxCd2x+C9Mqw/0HZPjpr1faUFVYX4W3hPw9Y6HXB/q ok6umWFWBqQWLErRhMqCKvZMokfKfchyPzfR2MUTKiBOg2GQTnha+3yxjUQ4hdWNnIux g8zxigQxW3RVSupAmcCHaKsp5Gc8a6Dsfp7fsKqMvCfc6T5ozD7APndLLVwIKAC8Vrpn cvNsEI0tDKDJnSGKdVR85lG66Mx1R8V4SB7LT27mybH90b5RLMA7QwByH2VgJ4np0CCR fQPfy72lyMysxROXaF7d65u8TG4JNhnut6kUBlfdLmnMUSZgLUA+9OQRZMlZM1oWROnL RbAg== X-Gm-Message-State: AOAM530aFuo5N2e7qGOaS6M9NkjQ/gBFzzX9NZ8HatdPSyGh9QqU/x3j O869xqu95hWFyJop1Plsbgw/b4/YnxY= X-Google-Smtp-Source: ABdhPJwswYr96p0T4bhaCiYByYrvfmHP5VDsroNG1S7kV3+r7MlxSkDkBrq/Z8N9NvNm4NgugxuMuw== X-Received: by 2002:a05:6000:1867:: with SMTP id d7mr1271457wri.21.1639592867044; Wed, 15 Dec 2021 10:27:47 -0800 (PST) Received: from ?IPV6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.googlemail.com with ESMTPSA id o5sm2562162wrx.83.2021.12.15.10.27.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Dec 2021 10:27:46 -0800 (PST) Sender: Paolo Bonzini Message-ID: Date: Wed, 15 Dec 2021 19:27:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH] KVM: Move VM's worker kthreads back to the original cgroups before exiting. Content-Language: en-US To: Vipin Sharma , seanjc@google.com, "Michael S. Tsirkin" Cc: dmatlack@google.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20211214050708.4040200-1-vipinsh@google.com> From: Paolo Bonzini In-Reply-To: <20211214050708.4040200-1-vipinsh@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/14/21 06:07, Vipin Sharma wrote: > > KVM terminates the worker kthreads by calling kthread_stop() which waits > on the signal generated by exit_mm() in do_exit() during kthread's exit. Instead of "signal", please spell it as "the 'exited' completion, triggered by exit_mm(), via mm_release(), during the kthread's exit". That makes things a bit clearer. So the issue is that the kthread_stop happens around the time exit_task_work() destroys the VM, but the process can go on and signal its demise to the parent process before the kthread has been completely dropped. Not even close() can fix it, though it may reduce the window completely, so I agree that this is a bug and vhost has the same bug too. Due to the issue with kthreadd_task not being exported, perhaps you can change cgroup_attach_task_all to use kthreadd_task if the "from" argument is NULL? Paolo