Received: by 10.223.185.116 with SMTP id b49csp1020878wrg; Fri, 16 Feb 2018 10:58:11 -0800 (PST) X-Google-Smtp-Source: AH8x227k+UOqEOaAJ8RkZio67HQ3b7z76zSoqxQSQuY3cdw43nI63NyuWfrnTI4Mk3DICQOgMsLS X-Received: by 2002:a17:902:36a:: with SMTP id 97-v6mr6830508pld.365.1518807491315; Fri, 16 Feb 2018 10:58:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518807491; cv=none; d=google.com; s=arc-20160816; b=hJ6j4wtemcQ90vKxGaVyHU88R4hO+e5G6uvkCxofrXQRveULcREtc3naEX/dq2FASN GjwksrLydO2vS8bPV2CtLMdJu0GqOgXWcwvx7iiZ1FQWhJXWUxfDUMPJkEKKHruU/ZOZ X6gCq+oXKhUwOUMBYk+1JYA/dFDXSeXOaeVCLuJhFM484ERs+SR+hkoIsylCcsAoiTRI zepTVg7KPk7JUuY0eMwSXnb2qti++wA3kvgw4cjbIsxeTfTKAlGdPq64sD8s1vN+SX6S l34eDegkh294vmRPxHcAG++DtznABOEv3uD2wvjK4QyyzKmHau3WJoG44gHiqRNsTFBa n4RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=o6KMD2TJj9m2bX52I2ryneKkkjGCuQvRiT8J4JS5q0U=; b=KdImTj4yCEbLNIsRzk5Ftgxser9DpoRAnWQf2E1n4npjLk4B+vDe6kYQdVW0zOlfOa XJqdauUD68miQmoV/Oi/nnNJM7RGugqqapRzCgRoONL6PgVSgNOvFMkExYitI/CASTbv yfK+m/pyAUWeW7nQTId0Sh4OadyxwdVwFYvi7IYoZDqhEjllYQn9veRKGs3e/9siGQw1 LM3antG0/gAsom/ZuCZ6souQyxjqdjHgPEgIpT0Tz+KOkp01iN5yAFQC8MnWRAo6+DQE xjuBuw+y5+KoxyKq1vP7sTz8dZRPbhmVG2zNCelKKQs3sF+vhD/RI6lDUMBEUQ6YB6st qLCw== ARC-Authentication-Results: i=1; mx.google.com; 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 g12-v6si3548603pla.226.2018.02.16.10.57.56; Fri, 16 Feb 2018 10:58:11 -0800 (PST) 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; 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 S933505AbeBPK3R (ORCPT + 99 others); Fri, 16 Feb 2018 05:29:17 -0500 Received: from mx2.suse.de ([195.135.220.15]:41107 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932082AbeBPK3P (ORCPT ); Fri, 16 Feb 2018 05:29:15 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3D53BAC39; Fri, 16 Feb 2018 10:29:14 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 5DD991E04F8; Fri, 16 Feb 2018 11:29:13 +0100 (CET) Date: Fri, 16 Feb 2018 11:29:13 +0100 From: Jan Kara To: t.vivek@samsung.com Cc: jack@suse.cz, amir73il@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, pankaj.m@samsung.com, Kunal Shubham Subject: Re: [PATCH] fanotify: allow freeze on suspend when waiting for response from userspace Message-ID: <20180216102913.jcgvc5rhjqtzlkb6@quack2.suse.cz> References: <1518774280-38090-1-git-send-email-t.vivek@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1518774280-38090-1-git-send-email-t.vivek@samsung.com> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 16-02-18 15:14:40, t.vivek@samsung.com wrote: > From: Vivek Trivedi > > If fanotify userspace response server thread is frozen first, > it may fail to send response from userspace to kernel space listener. > In this scenario, fanotify response listener will never get response > from userepace and fail to suspend. > > Use freeze-friendly wait API to handle this issue. > > Same problem was reported here: > https://bbs.archlinux.org/viewtopic.php?id=232270 > > Freezing of tasks failed after 20.005 seconds > (1 tasks refusing to freeze, wq_busy=0) > > Backtrace: > [] (__schedule) from [] (schedule+0x4c/0xa4) > [] (schedule) from [] (fanotify_handle_event+0x1c8/0x218) > [] (fanotify_handle_event) from [] (fsnotify+0x17c/0x38c) > [] (fsnotify) from [] (security_file_open+0x88/0x8c) > [] (security_file_open) from [] (do_dentry_open+0xc0/0x338) > [] (do_dentry_open) from [] (vfs_open+0x54/0x58) > [] (vfs_open) from [] (do_last.isra.10+0x45c/0xcf8) > [] (do_last.isra.10) from [] (path_openat+0x424/0x600) > [] (path_openat) from [] (do_filp_open+0x3c/0x98) > [] (do_filp_open) from [] (do_sys_open+0x120/0x1e4) > [] (do_sys_open) from [] (SyS_open+0x28/0x2c) > [] (SyS_open) from [] (__sys_trace_return+0x0/0x20) Yeah, good catch. > @@ -63,7 +64,9 @@ static int fanotify_get_response(struct fsnotify_group *group, > > pr_debug("%s: group=%p event=%p\n", __func__, group, event); > > - wait_event(group->fanotify_data.access_waitq, event->response); > + while (!event->response) > + wait_event_freezable(group->fanotify_data.access_waitq, > + event->response); But if the process gets a signal while waiting, we will just livelock the kernel in this loop as wait_event_freezable() will keep returning ERESTARTSYS. So you need to be a bit more clever here... Honza -- Jan Kara SUSE Labs, CR