Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5849935imu; Wed, 30 Jan 2019 04:45:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN5zRBZsSOkpG4Z5EiHKBYgcxYAJ9QjwRhljUQHZODH246AhgfLLWFL2Dh55BS3bxx6IjXDh X-Received: by 2002:a63:de04:: with SMTP id f4mr27143495pgg.292.1548852341929; Wed, 30 Jan 2019 04:45:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548852341; cv=none; d=google.com; s=arc-20160816; b=uYSefEKpFQDVGo3sXNyjyUBniJwt2w/+qJ4a3IQZ5JEp7JIA05POZ5Y2Mppuwd+jkp bsB2qDGUGM/TVQcAQ2WuqK+r1jVGEjK5hnGMrSfMbTHml5g2zDB+afE1yDumXzCacIzW aR2eLHIc8+DdubbfbgaCJsaAaVH3MGVuG70m2ZTdMNkGfgnmkAe0VaR3IcHzMXE1UkQy IuKTbaK6qUciflaLrB+/tV5k/mkKAS7AaHbwZp50wxZAQQPH75xWvTHeU44eHfESDcLb 375hRluAnDjD6+5ygWJpnFB+Hm2NvjOHbzTJPtkMrzGBxUTTxBv15r8YhZ8EihQW5cN1 o/wQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gR8hjRmommIPz3aLtYKpIHs+oBCBI/oZoS9lhEjaZDg=; b=gW6i9c8czornyHTwEiB6slqiDtlNvdPcfkjygrsHDHrQV97/HbPVDNmLz8PsXqEGrd yO36zoobYkAeRuyJ75EBPIuGa2sZi+58jSjdwGWQI3f//gwIaF3DnzZBxOJayoRKGzGN wU99daECW4gjPdapIDvIZF4cK22xiVK1S7jExF0X975OIP1DCnZKcjy/iE+iHeKsS1ZA vsnOTnOMsweHuAJXJxwLo5P+LkGptSAo3DG5VBqGZW6Sx7xI87EVWWi360ZWVW1csULb fyE1p4yR1o4HmuXmvSNrKFGutMsruLynHMqhKN7y5aHlW+bxu59u9UDzglGH48gsL0yZ oqDQ== 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 c191si1457988pfg.72.2019.01.30.04.45.26; Wed, 30 Jan 2019 04:45:41 -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 S1730886AbfA3MpQ (ORCPT + 99 others); Wed, 30 Jan 2019 07:45:16 -0500 Received: from mx2.suse.de ([195.135.220.15]:41406 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727946AbfA3MpP (ORCPT ); Wed, 30 Jan 2019 07:45:15 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 41B7BAE88; Wed, 30 Jan 2019 12:45:13 +0000 (UTC) From: Vlastimil Babka To: Andrew Morton , Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-api@vger.kernel.org, Peter Zijlstra , Greg KH , Jann Horn , Jiri Kosina , Dominique Martinet , Andy Lutomirski , Dave Chinner , Kevin Easton , Matthew Wilcox , Cyril Hrubis , Tejun Heo , "Kirill A . Shutemov" , Daniel Gruss , Vlastimil Babka , Jiri Kosina Subject: [PATCH 2/3] mm/filemap: initiate readahead even if IOCB_NOWAIT is set for the I/O Date: Wed, 30 Jan 2019 13:44:19 +0100 Message-Id: <20190130124420.1834-3-vbabka@suse.cz> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130124420.1834-1-vbabka@suse.cz> References: <20190130124420.1834-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Kosina preadv2(RWF_NOWAIT) can be used to open a side-channel to pagecache contents, as it reveals metadata about residency of pages in pagecache. If preadv2(RWF_NOWAIT) returns immediately, it provides a clear "page not resident" information, and vice versa. Close that sidechannel by always initiating readahead on the cache if we encounter a cache miss for preadv2(RWF_NOWAIT); with that in place, probing the pagecache residency itself will actually populate the cache, making the sidechannel useless. Originally-by: Linus Torvalds Cc: Dominique Martinet Cc: Andy Lutomirski Cc: Dave Chinner Cc: Kevin Easton Cc: Matthew Wilcox Cc: Cyril Hrubis Cc: Tejun Heo Cc: Kirill A. Shutemov Cc: Daniel Gruss Signed-off-by: Jiri Kosina Signed-off-by: Vlastimil Babka --- mm/filemap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 9f5e323e883e..7bcdd36e629d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2075,8 +2075,6 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb, page = find_get_page(mapping, index); if (!page) { - if (iocb->ki_flags & IOCB_NOWAIT) - goto would_block; page_cache_sync_readahead(mapping, ra, filp, index, last_index - index); -- 2.20.1