Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1331167imu; Wed, 9 Jan 2019 16:19:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN7sLelZwt5I+lp0BdNlhOcbktsw7rEu8vW6wVCfI3KS3RGz59dvEN0I1vAeokY9x63h7PIu X-Received: by 2002:a62:1a91:: with SMTP id a139mr8305912pfa.64.1547079599576; Wed, 09 Jan 2019 16:19:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547079599; cv=none; d=google.com; s=arc-20160816; b=yuzdon5CUfwjhwVdYpaWdviikP1kuzEF7c49tdWqAUvNc/Lk2jj9hCkpS1HGPyYx08 GLTWye5KBD0pBzRXH/Xbt5bnB1bvT2DpeLNsF11CnYV2Il8e4GSU/ujyS5/+1z2QEMXD eq5hFgk2rUUIZr2R1b6rADNtJoal//Y9NRuvnXFa+kkDjyX3IBazXKDra5lcJuVTD9bR 4KF1nU8LlguW8eZj+liOMlinCC5+A1nARQKkkuJpKBcp6XIqcrHLfRtrOxnXVbbQL8c7 4HdGsCgI1XsNddVMw1MfIYM7dTBja25hHEhbyUebBR/XECrTfQrZ1JEFhrCkmwxsvvZ7 fqTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature; bh=qcc0vpPwlj953Qdb+Xr4syq8PvGm8X0FWC3fECLLsco=; b=m2DWNhJ5O+fmvjbCLYktcfWHKzjrJt98gHeelrmtUQey/PWIdtLuJf7ROBW26oU5KU 6KwtMh/hc3hbxZWzEA/f1KDuFIlEB8F74RxEK848jYzfjBPXKiUwFf/kgc7BhVc/mvQ8 Xy5FUqbSVyoQdhq0LE/9vF/zgD6WuaezKMCT0UJms1fqDzYzGyNbSVobf+RS0UDhWI/W kk6bdHozYBP+na/3MfITZLPz5QJ3paRKVX3bH0gvMmIihf00HNtKgGCqpIDxFDYB12IG wed3qNYeMm5Yl9HtAJ0wsYckuBk26YtueoZizoWhhOVB5PxaPMBahuz2HhUUEaFyoIrY FvKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EpUkk7gO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si12397870plb.224.2019.01.09.16.19.43; Wed, 09 Jan 2019 16:19:59 -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; dkim=pass header.i=@linaro.org header.s=google header.b=EpUkk7gO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726869AbfAJARY (ORCPT + 99 others); Wed, 9 Jan 2019 19:17:24 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:47045 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726286AbfAJARY (ORCPT ); Wed, 9 Jan 2019 19:17:24 -0500 Received: by mail-qt1-f196.google.com with SMTP id y20so10467631qtm.13 for ; Wed, 09 Jan 2019 16:17:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=qcc0vpPwlj953Qdb+Xr4syq8PvGm8X0FWC3fECLLsco=; b=EpUkk7gO8LP9EZD/RPXcBb0ugDtO98RYty44nI7wqwvlkuvp9J56zY/T5WhEhzOjLu Oo9c1257iH6VrPDQzY3Oy17MVXzF43J6lpxFXj81qyapfA2WCyllb5qrgiBS3PbnuZtc q0CiIUPDVo1ZZpm0z4J0u0n/0S03OPqwBBBMY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=qcc0vpPwlj953Qdb+Xr4syq8PvGm8X0FWC3fECLLsco=; b=ieL1JMrBFXmdHsintgukzNeA1Tf47b0M61yG/tqSwO1+jtu/rzd9meoGBBdcgQ5Ham +VVk1oXwacdkA1UtVgNMQtBT47oxVdyial/pTfu64luJGFgBy/UgsxVcW/taG/6NSj1J TYg6xCbNFoXvlpf9DSBlAWzHtvE9sgZZMzsh1SRBcEDQU8teJmPGcld2YvozRakXzA67 9NkLbHkxYdsKIvY+QB+jK+2vByTDLil7dZwWdCEuj7b6skOXbJSdSJME5NGYo78ilEM7 Z6nReGEMBJ/xDnB0bk+hNSwlkVaj7e0i85uke3RdG5xeu2UicyJ5zcAxzQFkEbxGKHJj 0y5Q== X-Gm-Message-State: AJcUukfjrMuJloVXWatL4Zcplm0QSy9k3E/9yDIkpE0CWVtwdL7f4DSn SE1MZDtj0gy6qQbzfcpFjZiZhlXTrMk= X-Received: by 2002:aed:2558:: with SMTP id w24mr7626698qtc.183.1547079443457; Wed, 09 Jan 2019 16:17:23 -0800 (PST) Received: from xanadu.home (modemcable228.104-82-70.mc.videotron.ca. [70.82.104.228]) by smtp.gmail.com with ESMTPSA id d199sm33404852qkc.76.2019.01.09.16.17.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Jan 2019 16:17:22 -0800 (PST) Date: Wed, 9 Jan 2019 19:17:20 -0500 (EST) From: Nicolas Pitre To: Greg Kroah-Hartman cc: Dave Mielke , linux-kernel@vger.kernel.org Subject: [PATCH 7/6] vcs: restore and document initial POLLPRI event Message-ID: User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Restore and document the forced initial POLLPRI event reporting when poll() is used for the first time. This used to be the implemented behavior before recent changes. Because of the way poll() is implemented, this prevents losing an event happening between the last read() and the first poll() invocation. Since poll() for /dev/vcs* was not always supported, user space probes for its availability as follows: int fd = open("/dev/vcsa", O_RDONLY); struct pollfd p = { .fd = fd, .events = POLLPRI }; available = (poll(&p, 1, 0) == 1); Semantically, it makes sense to signal the first event as such even if it might be spurious. The screen could be modified, and modified back to its initial state before we get to read it, so users must be prepared for that anyway. Signed-off-by: Nicolas Pitre diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c index 1d887113ff..160f46115a 100644 --- a/drivers/tty/vt/vc_screen.c +++ b/drivers/tty/vt/vc_screen.c @@ -140,6 +140,15 @@ vcs_poll_data_get(struct file *file) poll->cons_num = console(file_inode(file)); init_waitqueue_head(&poll->waitq); poll->notifier.notifier_call = vcs_notifier; + /* + * In order not to lose any update event, we must pretend one might + * have occurred before we have a chance to register our notifier. + * This is also how user space has come to detect which kernels + * support POLLPRI on /dev/vcs* devices i.e. using poll() with + * POLLPRI and a zero timeout. + */ + poll->event = VT_UPDATE; + if (register_vt_notifier(&poll->notifier) != 0) { kfree(poll); return NULL;