Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5226166ybl; Tue, 27 Aug 2019 01:07:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUS5WzBFTnowQNauK/uef8PnpcsYPMoivg4Y9Sbumt2g/KRbW5Em7Z3yGzeDrZdnacz9cM X-Received: by 2002:a17:902:968e:: with SMTP id n14mr8749528plp.312.1566893225768; Tue, 27 Aug 2019 01:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566893225; cv=none; d=google.com; s=arc-20160816; b=sK11IqeatGzUtaE69Izy/E69nnC03TYMkClo3GSqYB7CZUo3GbkhdyMSwdzF818tx2 b1dMULDjAWd/InREtEq9ACDIDQZBdqVMQA3/cvaPdZXA4h39rKuA4yWManjA/X5ew3sW ASpwLVD9LZ9jIHtJXmEZNvrbRZto8LXpZojXDZWUsHMBEIFxC9eug7SyJDxcfW5ctpNs 0hTn8eixGCGJQseH6lF3bNXyGKWWAHjbPGseVkMkZ2Bb5kyoY+CBtAZVBRrFDCcv/k7l CWmblsH1Mlm/L7E0YyNP/4w6i4qRh0EYw3HGO+CiKyADkfKf9zU/Ta/ccY1aSOm0gUIC WIrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nAy5WN5nAit6SdaTMAKtKfpbru5ruqu8xee/RSB6UlU=; b=cEcVFxIJviAjD9fQ3wxuUYHlGn2+8uYYLGAFryevd6K8zkib2M33P+CEPJ9VKWd/dJ axP/8wRg7iGSTvvgxVIdRaQDMkrQ8cOrewT/xbwCdjqYpw/IDmIa1+7al06N8X5Ojns0 HixwXmgeyyzzloIN72JmTVg7nX4LwWaYHaLzx83sU7s1oM0LU5gVn2eE3NMATOPkmMVd F0aRQtZoP3wPBn9D8n9/xXxhv/535m4ytdPcp0JjuHMFxdKGmuCuS7/uW1FCLTU4M+Nw TnIffuuqI4kAYT7zhswOZl0hqpZ6ydtEcxsWUmNtElCRiMo3q8qO/zvzr8XgzXBO5R3z qPuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sfYjY5oF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a35si2200440pla.5.2019.08.27.01.06.50; Tue, 27 Aug 2019 01:07:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sfYjY5oF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732883AbfH0IFo (ORCPT + 99 others); Tue, 27 Aug 2019 04:05:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:35600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732430AbfH0IFn (ORCPT ); Tue, 27 Aug 2019 04:05:43 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 132892173E; Tue, 27 Aug 2019 08:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566893142; bh=VXwVDTiltX/zKo5qXYVnCLq9PB59320XB21Bwv/rLUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sfYjY5oFDUSko45BFb1TMMTWf2IO/5raZ02VVIC2RLTwbzLNI5Q53dcCuP//wJGpf EMHMfmbEmL+pw3Ssadnmwzbnf9/ruKFULWUbQsDPVdc/b3ylD72hNcMWGMTRLVucxi 668QtAdOWJ7X793esEoUbYVvtiki/XPs9rNd+HDw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Xing , Joseph Qi , Caspar Zhang , Suren Baghdasaryan , Johannes Weiner , Ingo Molnar , Peter Zijlstra , Andrew Morton , Linus Torvalds Subject: [PATCH 5.2 134/162] psi: get poll_work to run when calling poll syscall next time Date: Tue, 27 Aug 2019 09:51:02 +0200 Message-Id: <20190827072743.237942008@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072738.093683223@linuxfoundation.org> References: <20190827072738.093683223@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Xing commit 7b2b55da1db10a5525460633ae4b6fb0be060c41 upstream. Only when calling the poll syscall the first time can user receive POLLPRI correctly. After that, user always fails to acquire the event signal. Reproduce case: 1. Get the monitor code in Documentation/accounting/psi.txt 2. Run it, and wait for the event triggered. 3. Kill and restart the process. The question is why we can end up with poll_scheduled = 1 but the work not running (which would reset it to 0). And the answer is because the scheduling side sees group->poll_kworker under RCU protection and then schedules it, but here we cancel the work and destroy the worker. The cancel needs to pair with resetting the poll_scheduled flag. Link: http://lkml.kernel.org/r/1566357985-97781-1-git-send-email-joseph.qi@linux.alibaba.com Signed-off-by: Jason Xing Signed-off-by: Joseph Qi Reviewed-by: Caspar Zhang Reviewed-by: Suren Baghdasaryan Acked-by: Johannes Weiner Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/sched/psi.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -1131,7 +1131,15 @@ static void psi_trigger_destroy(struct k * deadlock while waiting for psi_poll_work to acquire trigger_lock */ if (kworker_to_destroy) { + /* + * After the RCU grace period has expired, the worker + * can no longer be found through group->poll_kworker. + * But it might have been already scheduled before + * that - deschedule it cleanly before destroying it. + */ kthread_cancel_delayed_work_sync(&group->poll_work); + atomic_set(&group->poll_scheduled, 0); + kthread_destroy_worker(kworker_to_destroy); } kfree(t);