Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1152889ybi; Wed, 3 Jul 2019 10:23:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCwCtR8K6Iw/J0xa8FPpK8xKIqO9lTBXRzWSjw6m+kIqmC95xBrQaxZYsFME68z+Fvr51A X-Received: by 2002:a17:90a:19d:: with SMTP id 29mr14322618pjc.71.1562174585613; Wed, 03 Jul 2019 10:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562174585; cv=none; d=google.com; s=arc-20160816; b=vZsn2ggKd/RGFuI+pNvhzOhqZc3Kd3qJAYerTRfc5BR6+XBTtq3UT3ZjKtQgIr+vpZ UhEXr3EAxJMNf/iqVHk8wXXmdc4idxf7z3igTqbzo1awuARWv/LGEVoz7oWkMNS+LoEU yosOImx/OGKcQacCxCGia0P9eFaMG6O9tVDO6t2rQFt+2KH5U7WEmN27jpDq5GkehFMm dpg3dNeOLeORT64N5avHduT3eOuSUlTDQJWCmtqni8WXyMJK0x205Cmw93v9Boo80Qok 56ULq0pUwJ7xGhmqPdrFRsdtkdSBoy+3It9Stl64XmWwoeN3+Ij6icn9a66zVDKvS/Dr bAWg== 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; bh=lZN3AfYMOjfLYKC1dQ0sLvQ6ffAZsFnK1d8rGNn1HlU=; b=Nx+/95D5slZMQD2egqrCPETvTjYei9duuV99ztdVC/1kFYZJ2ul8WgVMoYhp4Geib7 MGMmbdScNUP7NkORk26G63lMVqMbHSQfrr6n/4vR63F+k2mhJmjUbDMxx/1yqLiKoj4y Twb2+Bp1iG61jW5gBB09hw8brN9hyLQ2g9/4gstoQ3nWszRFQ1b6dVdQ4nOCkDboV+5h g9tD1Y4RIjbrE8iD2xSG2v2l4tzD5SYdp35SbtD5Fj1gTLGrUMjKsVs1tqzBPJ2Duz5Z pq+fft3Umk/mA8HnuBSByW4Hpfo6cT02PGI1z+tAqrz+TdKGQWibAh0Qc+BLYhot+o+1 fhfA== 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 cx7si2352597pjb.51.2019.07.03.10.22.50; Wed, 03 Jul 2019 10:23:05 -0700 (PDT) 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 S1727259AbfGCRVu (ORCPT + 99 others); Wed, 3 Jul 2019 13:21:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:49336 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727119AbfGCRVu (ORCPT ); Wed, 3 Jul 2019 13:21:50 -0400 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 3FC2DABF1; Wed, 3 Jul 2019 17:21:47 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 147E11E0D71; Wed, 3 Jul 2019 19:21:41 +0200 (CEST) Date: Wed, 3 Jul 2019 19:21:41 +0200 From: Jan Kara To: Boaz Harrosh Cc: Jan Kara , Dave Chinner , Kent Overstreet , Linus Torvalds , Dave Chinner , Waiman Long , Peter Zijlstra , Linux List Kernel Mailing , linux-fsdevel , linux-bcache@vger.kernel.org, "Darrick J . Wong" , Zach Brown , Jens Axboe , Josef Bacik , Alexander Viro , Andrew Morton , Tejun Heo , Amir Goldstein Subject: Re: [PATCH] mm: Support madvise_willneed override by Filesystems Message-ID: <20190703172141.GD26423@quack2.suse.cz> References: <20190610191420.27007-1-kent.overstreet@gmail.com> <20190611011737.GA28701@kmo-pixel> <20190611043336.GB14363@dread.disaster.area> <20190612162144.GA7619@kmo-pixel> <20190612230224.GJ14308@dread.disaster.area> <20190619082141.GA32409@quack2.suse.cz> <27171de5-430e-b3a8-16f1-7ce25b76c874@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <27171de5-430e-b3a8-16f1-7ce25b76c874@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 03-07-19 04:04:57, Boaz Harrosh wrote: > On 19/06/2019 11:21, Jan Kara wrote: > <> > > Yes, I have patch to make madvise(MADV_WILLNEED) go through ->fadvise() as > > well. I'll post it soon since the rest of the series isn't really dependent > > on it. > > > > Honza > > > > Hi Jan > > Funny I'm sitting on the same patch since LSF last. I need it too for other > reasons. I have not seen, have you pushed your patch yet? > (Is based on old v4.20) Your patch is wrong due to lock ordering. You should not call vfs_fadvise() under mmap_sem. So we need to do a similar dance like madvise_remove(). I have to get to writing at least XFS fix so that the madvise change gets used and post the madvise patch with it... Sorry it takes me so long. Honza > > ~~~~~~~~~ > From fddb38169e33d23060ddd444ba6f2319f76edc89 Mon Sep 17 00:00:00 2001 > From: Boaz Harrosh > Date: Thu, 16 May 2019 20:02:14 +0300 > Subject: [PATCH] mm: Support madvise_willneed override by Filesystems > > In the patchset: > [b833a3660394] ovl: add ovl_fadvise() > [3d8f7615319b] vfs: implement readahead(2) using POSIX_FADV_WILLNEED > [45cd0faae371] vfs: add the fadvise() file operation > > Amir Goldstein introduced a way for filesystems to overide fadvise. > Well madvise_willneed is exactly as fadvise_willneed except it always > returns 0. > > In this patch we call the FS vector if it exists. > > NOTE: I called vfs_fadvise(..,POSIX_FADV_WILLNEED); > (Which is my artistic preference) > > I could also selectively call > if (file->f_op->fadvise) > return file->f_op->fadvise(..., POSIX_FADV_WILLNEED); > If we fear theoretical side effects. I don't mind either way. > > CC: Amir Goldstein > CC: Miklos Szeredi > Signed-off-by: Boaz Harrosh > --- > mm/madvise.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/mm/madvise.c b/mm/madvise.c > index 6cb1ca93e290..6b84ddcaaaf2 100644 > --- a/mm/madvise.c > +++ b/mm/madvise.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > > #include > > @@ -303,7 +304,8 @@ static long madvise_willneed(struct vm_area_struct *vma, > end = vma->vm_end; > end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; > > - force_page_cache_readahead(file->f_mapping, file, start, end - start); > + vfs_fadvise(file, start << PAGE_SHIFT, (end - start) << PAGE_SHIFT, > + POSIX_FADV_WILLNEED); > return 0; > } > > -- > 2.20.1 > -- Jan Kara SUSE Labs, CR