From patchwork Sun Aug 25 00:54:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11113181 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 562C61399 for ; Sun, 25 Aug 2019 00:54:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 17A6822CE9 for ; Sun, 25 Aug 2019 00:54:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="VrpFC1Sa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17A6822CE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 28EDF6B04FF; Sat, 24 Aug 2019 20:54:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 218586B0501; Sat, 24 Aug 2019 20:54:56 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17C576B0502; Sat, 24 Aug 2019 20:54:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0058.hostedemail.com [216.40.44.58]) by kanga.kvack.org (Postfix) with ESMTP id EDF2E6B04FF for ; Sat, 24 Aug 2019 20:54:55 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 91B514820 for ; Sun, 25 Aug 2019 00:54:55 +0000 (UTC) X-FDA: 75859130550.08.space69_481215c01285b X-Spam-Summary: 2,0,0,c4a73ad1383dfa35,d41d8cd98f00b204,akpm@linux-foundation.org,:akpm@linux-foundation.org:caspar@linux.alibaba.com:hannes@cmpxchg.org:joseph.qi@linux.alibaba.com:kerneljasonxing@linux.alibaba.com::mingo@redhat.com:mm-commits@vger.kernel.org:peterz@infradead.org:stable@vger.kernel.org:surenb@google.com:torvalds@linux-foundation.org,RULES_HIT:41:355:379:800:960:966:967:973:988:989:1260:1263:1345:1381:1431:1437:1534:1542:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2525:2559:2563:2682:2685:2859:2897:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4385:5007:6119:6261:6653:6737:7576:7875:7903:9025:9391:9545:9707:10004:10913:11026:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12679:12783:12986:13053:13161:13229:14181:14721:14849:21080:21212:21324:21433:21450:21451:21627:21740:21795:21819:21939:30006:30012:30041:30051:30 054:3007 X-HE-Tag: space69_481215c01285b X-Filterd-Recvd-Size: 3521 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Sun, 25 Aug 2019 00:54:55 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (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 C7F3A2190F; Sun, 25 Aug 2019 00:54:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566694494; bh=YpmFU5fs/NJMrrrVE0ZhpttDS0wDvYzWyG+8KwPKHfM=; h=Date:From:To:Subject:From; b=VrpFC1Saajfsx9VLQwtvXAPYy7hXdVbLfCrBXyb4Wm4IwKNAet80OW8STG8HkbGcU Ys2WyzPJg/SLAeXcwZdtRgjbuCxmRaNTHYhqmelHe33dSrdlxW8tF31mhLBWssL+Iz UHP4cbGrg4r+RMlWxnvY3HN+CbP6lCvnjv0HQg8I= Date: Sat, 24 Aug 2019 17:54:53 -0700 From: akpm@linux-foundation.org To: akpm@linux-foundation.org, caspar@linux.alibaba.com, hannes@cmpxchg.org, joseph.qi@linux.alibaba.com, kerneljasonxing@linux.alibaba.com, linux-mm@kvack.org, mingo@redhat.com, mm-commits@vger.kernel.org, peterz@infradead.org, stable@vger.kernel.org, surenb@google.com, torvalds@linux-foundation.org Subject: [patch 06/11] psi: get poll_work to run when calling poll syscall next time Message-ID: <20190825005453.mWr0lsMZh%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Jason Xing Subject: psi: get poll_work to run when calling poll syscall next time 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 --- kernel/sched/psi.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/kernel/sched/psi.c~psi-get-poll_work-to-run-when-calling-poll-syscall-next-time +++ a/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);