From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7162AC433E8 for ; Thu, 16 Jul 2020 13:19:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 30B0E20787 for ; Thu, 16 Jul 2020 13:19:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="EkZKARTO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30B0E20787 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C88178D001D; Thu, 16 Jul 2020 09:19:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C377E8D0012; Thu, 16 Jul 2020 09:19:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B273C8D001D; Thu, 16 Jul 2020 09:19:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id 992468D0012 for ; Thu, 16 Jul 2020 09:19:37 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4ED7B1EE6 for ; Thu, 16 Jul 2020 13:19:37 +0000 (UTC) X-FDA: 77043995994.17.tiger54_2c0565126f02 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 88E86180D018B for ; Thu, 16 Jul 2020 13:19:36 +0000 (UTC) X-HE-Tag: tiger54_2c0565126f02 X-Filterd-Recvd-Size: 3042 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jul 2020 13:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=WEQiCBMMUNKEUFHyzcb5Rpc/CbMmuXqhvIERsytx/G8=; b=EkZKARTO1n+Jc8mgTGW8iuFXhb thHBz9J+4zMmxQpyDabGDoVmIS+aKFLPIgfIr793sfNEChsxhi/PN5y1eigH5phu3iGPFbzJGpeqR oWY7QtkQtoHsfTCa+LyOhMgJBBXOWi1Htd4HpsmzuBTke/S9skePv4Ac7Tw7BVWdbB8XfZeg9HBQT 1zvYZN/DZ42PisgHb9EBnmON5XGdXsQUJlUcQwT09HE1uBcvmxB4orvpi1CAg3ZbVeVzrEKrOWRt6 tnP/Kpk4N0G45HJtUvYoZbiROd/+yKrns8So7a2yQj6IhynArheTfWxH+5ko4nBboUktV8FLikk5X otmiI6GQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw3nN-0003AX-4f; Thu, 16 Jul 2020 13:19:29 +0000 Date: Thu, 16 Jul 2020 14:19:29 +0100 From: Matthew Wilcox To: Eric Biggers Cc: Nicholas Piggin , Dave Chinner , akpm@linux-foundation.org, Marco Elver , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Paul E. McKenney" , syzbot , syzkaller-bugs@googlegroups.com, Will Deacon Subject: Re: KCSAN: data-race in generic_file_buffered_read / generic_file_buffered_read Message-ID: <20200716131929.GL12769@casper.infradead.org> References: <0000000000004a4d6505aa7c688a@google.com> <20200715152912.GA2209203@elver.google.com> <20200715163256.GB1167@sol.localdomain> <20200715234203.GK5369@dread.disaster.area> <20200716030357.GE1167@sol.localdomain> <1594880070.49b50i0a1p.astroid@bobo.none> <20200716065454.GI1167@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200716065454.GI1167@sol.localdomain> X-Rspamd-Queue-Id: 88E86180D018B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: On Wed, Jul 15, 2020 at 11:54:54PM -0700, Eric Biggers wrote: > > >> > Concurrent reads on the same file descriptor are allowed. Not with sys_read(), > > >> > as that implicitly uses the file position. But it's allowed with sys_pread(), > > >> > and also with sys_sendfile() which is the case syzbot is reporting here. > > >> > > >> Concurrent read()s are fine, they'll just read from the same offset. > > >> > > > > > > Actually the VFS serializes concurrent read()'s on the same fd, at least for > > > regular files. > > > > Hmm, where? > > It's serialized by file->f_pos_lock. See fdget_pos(). What if we trylock either f_lock or f_pos_lock for readahead and just skip all the readahead code if it's already taken? I'd suggest that if there are two readers using the same struct file, this is probably not a workload that benefits greatly from readahead.