Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5646967rwd; Mon, 5 Jun 2023 06:45:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4tgiScgwn39vhRbUXkaovNhdtgmSNorQMflVfNDmD64FXSZPTUkFhSyr8sVkICQ6SWBhlP X-Received: by 2002:a05:6a20:2454:b0:106:c9b7:c93d with SMTP id t20-20020a056a20245400b00106c9b7c93dmr8440587pzc.19.1685972756931; Mon, 05 Jun 2023 06:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685972756; cv=none; d=google.com; s=arc-20160816; b=BZVaj6AzHloIC2Yf9cHIEIJxzqpKnMI5Cy3PmhmGYOxefdfv25PTViObunuFvHeb0s 1PKqx1xVzErEqdANlikLVHRpfVHzWVxWz6cznss7yn+DuQKDJV0PZKeTeRg1CWSkUPp2 98I1ZxFu3+UXSHYYVF5GPe2SNi0twE23iBMSaxUzLOE5Kxi5UixybH708Z4ws2PERNih e0iY99Hdas0yVIsAZFrFZXWBamsNfqOPBkeaBYDhgLssa99Az1p1t7K9+7HMmtSrYTSt zOQdnat37/Zfx/tL57tpiW4GXqRftuUDvMaW+viD3AQZavaA9ccN05lCNwBBhGSkMTN9 nEUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=fE6eT97yzH12os5SZGHmyPIjNlvh5xRQLosLvxOHz80=; b=lPIZyib6PgijmNXm/CP6OfpOBsoXuw8DY3MRD5Vu9mGzub2o0zzSn8cX8AsCFBcxzX GyYwmWuMCQPFWzAjkhMnZNOg6MwrY+Doxr4rNaPM6zGX+YyfgUYnV4/z4R1zjtBKgUQC xeycZDaNolRDPwxmMnwjJEwe1Y3EKRt1w8C0nUmaKhM9rGzS4BoPmbTyyu8RvuFY2c6H bx04zsFM0kmDXgWLDMBgtF4tzwVwgV3U76vFvtcmV7uPp76vc08TaUuzNv+QrmG3AEDG JdkzojRDA7/PsjhFnQbHcg3zdwZ7tsdaFh0EkIFnozQ3KBPHtJib8khxW7hlPu2+8043 C5Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="M754T/bQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a63d809000000b0054292b18a8esi5513232pgh.696.2023.06.05.06.45.25; Mon, 05 Jun 2023 06:45:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="M754T/bQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233038AbjFEN13 (ORCPT + 99 others); Mon, 5 Jun 2023 09:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbjFEN12 (ORCPT ); Mon, 5 Jun 2023 09:27:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 089B0D2 for ; Mon, 5 Jun 2023 06:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685971606; 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: in-reply-to:in-reply-to:references:references; bh=fE6eT97yzH12os5SZGHmyPIjNlvh5xRQLosLvxOHz80=; b=M754T/bQLZjMJBqyLGzsiLBsIuS6hG+QcCPmjrJQTRWZ2Zs7WaLc3D3TjnBzBeUM84mCPC 57sUDX+BWgFzTEapkB1z9T5d4Ah9GQuZlFns65MFwVqEVm0inM1uEUOl3bXOFCGmNHxM4G Xp6RWjEbFm+75xVd4Moofh6b1/8fOUw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-NUiRjT3UM7GVO2knb6Tq8Q-1; Mon, 05 Jun 2023 09:26:43 -0400 X-MC-Unique: NUiRjT3UM7GVO2knb6Tq8Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 686E91C05EAA; Mon, 5 Jun 2023 13:26:42 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.144]) by smtp.corp.redhat.com (Postfix) with SMTP id 1D7D81121314; Mon, 5 Jun 2023 13:26:33 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 5 Jun 2023 15:26:20 +0200 (CEST) Date: Mon, 5 Jun 2023 15:26:11 +0200 From: Oleg Nesterov To: "Eric W. Biederman" Cc: Mike Christie , linux@leemhuis.info, nicolas.dichtel@6wind.com, axboe@kernel.dk, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, stefanha@redhat.com, brauner@kernel.org Subject: Re: [PATCH 1/1] fork, vhost: Use CLONE_THREAD to fix freezer/ps regression Message-ID: <20230605132611.GB32275@redhat.com> References: <20230601183232.8384-1-michael.christie@oracle.com> <20230602192254.GD555@redhat.com> <87wn0l2or4.fsf@email.froward.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87wn0l2or4.fsf@email.froward.int.ebiederm.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/02, Eric W. Biederman wrote: > > Oleg Nesterov writes: > > > Hi Mike, > > > > sorry, but somehow I can't understand this patch... > > > > I'll try to read it with a fresh head on Weekend, but for example, > > > > On 06/01, Mike Christie wrote: > >> > >> static int vhost_task_fn(void *data) > >> { > >> struct vhost_task *vtsk = data; > >> - int ret; > >> + bool dead = false; > >> + > >> + for (;;) { > >> + bool did_work; > >> + > >> + /* mb paired w/ vhost_task_stop */ > >> + if (test_bit(VHOST_TASK_FLAGS_STOP, &vtsk->flags)) > >> + break; > >> + > >> + if (!dead && signal_pending(current)) { > >> + struct ksignal ksig; > >> + /* > >> + * Calling get_signal will block in SIGSTOP, > >> + * or clear fatal_signal_pending, but remember > >> + * what was set. > >> + * > >> + * This thread won't actually exit until all > >> + * of the file descriptors are closed, and > >> + * the release function is called. > >> + */ > >> + dead = get_signal(&ksig); > >> + if (dead) > >> + clear_thread_flag(TIF_SIGPENDING); > > > > this can't be right or I am totally confused. > > > > Another signal_wake_up() can come right after clear(SIGPENDING). > > Technically yes. ... > Beyond that clearing TIF_SIGPENDING is just an optimization so > the thread can sleep in schedule and not spin. Yes. So if another signal_wake_up() comes after clear(SIGPENDING) this code will spin in busy-wait loop waiting VHOST_TASK_FLAGS_STOP. Obviously not good and even deadlockable on UP && !PREEMPT. Oleg.