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=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 0BDACC11F66 for ; Tue, 13 Jul 2021 12:35:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0D5E61006 for ; Tue, 13 Jul 2021 12:35:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236164AbhGMMik (ORCPT ); Tue, 13 Jul 2021 08:38:40 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33706 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236137AbhGMMij (ORCPT ); Tue, 13 Jul 2021 08:38:39 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 83C3D22075; Tue, 13 Jul 2021 12:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1626179748; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nlezZmaJGKsn3wThAAqUns1S5039quPyWkLk1BLMszA=; b=L0Ik4SGLKPMprCMpIDZu5I9SJkk6iVnXbqXSILIKOJ1tUsAz+3nm9Fiv2/sQhIhFL9aOmi Xdd54ETzCRoMIv/6ptRzy+K8vp6P0oCs0DxP7fFszUwp7i+yxHOadd6Ea9UosE6mdaj5+9 3H6ZtOh5KYeEBpKjmeYcIikKLdDRKL4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1626179748; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nlezZmaJGKsn3wThAAqUns1S5039quPyWkLk1BLMszA=; b=k26gwy3dwwIlQyBP4N54gjqPfnfyayfHxU0JZPsEVY6lWzaQ34iMd6jTvkatBxRCs6Y6HK 8UfNH2RVTEz7qqDg== Received: from quack2.suse.cz (unknown [10.100.224.230]) by relay2.suse.de (Postfix) with ESMTP id 6FB26A3BBB; Tue, 13 Jul 2021 12:35:48 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 4DCC31E0BBC; Tue, 13 Jul 2021 14:35:48 +0200 (CEST) Date: Tue, 13 Jul 2021 14:35:48 +0200 From: Jan Kara To: Christoph Hellwig Cc: Jan Kara , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, "Darrick J. Wong" , Ted Tso , Dave Chinner , Matthew Wilcox , linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, Christoph Hellwig Subject: Re: [PATCH 03/14] mm: Protect operations adding pages to page cache with invalidate_lock Message-ID: <20210713123548.GA24271@quack2.suse.cz> References: <20210712163901.29514-1-jack@suse.cz> <20210712165609.13215-3-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org On Tue 13-07-21 07:25:05, Christoph Hellwig wrote: > Still looks good. That being said the additional conditional locking in > filemap_fault makes it fall over the readbility cliff for me. Something > like this on top of your series would help: Yeah, that's better. Applied, thanks. Honza > > diff --git a/mm/filemap.c b/mm/filemap.c > index fd3f94d36c49..0fad08331cf4 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -3040,21 +3040,23 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) > * Do we have something in the page cache already? > */ > page = find_get_page(mapping, offset); > - if (likely(page) && !(vmf->flags & FAULT_FLAG_TRIED)) { > + if (likely(page)) { > /* > - * We found the page, so try async readahead before > - * waiting for the lock. > + * We found the page, so try async readahead before waiting for > + * the lock. > */ > - fpin = do_async_mmap_readahead(vmf, page); > - } else if (!page) { > + if (!(vmf->flags & FAULT_FLAG_TRIED)) > + fpin = do_async_mmap_readahead(vmf, page); > + if (unlikely(!PageUptodate(page))) { > + filemap_invalidate_lock_shared(mapping); > + mapping_locked = true; > + } > + } else { > /* No page in the page cache at all */ > count_vm_event(PGMAJFAULT); > count_memcg_event_mm(vmf->vma->vm_mm, PGMAJFAULT); > ret = VM_FAULT_MAJOR; > fpin = do_sync_mmap_readahead(vmf); > - } > - > - if (!page) { > retry_find: > /* > * See comment in filemap_create_page() why we need > @@ -3073,9 +3075,6 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) > filemap_invalidate_unlock_shared(mapping); > return VM_FAULT_OOM; > } > - } else if (unlikely(!PageUptodate(page))) { > - filemap_invalidate_lock_shared(mapping); > - mapping_locked = true; > } > > if (!lock_page_maybe_drop_mmap(vmf, page, &fpin)) -- Jan Kara SUSE Labs, CR 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=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 1E8F1C07E95 for ; Tue, 13 Jul 2021 12:36:08 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2BC061006; Tue, 13 Jul 2021 12:36:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2BC061006 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1m3Hdu-0004rz-Gt; Tue, 13 Jul 2021 12:36:06 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3Hds-0004rl-VQ for linux-f2fs-devel@lists.sourceforge.net; Tue, 13 Jul 2021 12:36:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=nlezZmaJGKsn3wThAAqUns1S5039quPyWkLk1BLMszA=; b=DwW1Nv5yyFn2PSqWj9oM5jNjdE GNSw9kv1wKmH9OkGnDHEprXhEYtF97CnNQQMPTygJY+rd3qqc1vy8PJVrQ7/QS+HHW6uBefrD5HLb 4RwVJzEtlIRANZrAcm+xQtC3XFZTb4LZ//bFbfDIrR/FlIQPFvdA3KsXXN0dU6rOsam4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=nlezZmaJGKsn3wThAAqUns1S5039quPyWkLk1BLMszA=; b=CBiWn8f/3cTvyLTA2f+P8+qJyV 2m1z46rkByJO8TuCHYtVNZhmMNC1MGqIUCVvw8frJgNGo3bUylCS02hmtjcUDEOPe1FiqUtAMyQWj 8NaOHnkvYaQ2eIyv2QRJcI6q1xEji3fmu3Ke2mVyZr4D+ULoHsoLbRp4A4ew7izgnGpY=; Received: from smtp-out1.suse.de ([195.135.220.28]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) id 1m3Hdm-0001yw-CT for linux-f2fs-devel@lists.sourceforge.net; Tue, 13 Jul 2021 12:36:04 +0000 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 83C3D22075; Tue, 13 Jul 2021 12:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1626179748; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nlezZmaJGKsn3wThAAqUns1S5039quPyWkLk1BLMszA=; b=L0Ik4SGLKPMprCMpIDZu5I9SJkk6iVnXbqXSILIKOJ1tUsAz+3nm9Fiv2/sQhIhFL9aOmi Xdd54ETzCRoMIv/6ptRzy+K8vp6P0oCs0DxP7fFszUwp7i+yxHOadd6Ea9UosE6mdaj5+9 3H6ZtOh5KYeEBpKjmeYcIikKLdDRKL4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1626179748; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nlezZmaJGKsn3wThAAqUns1S5039quPyWkLk1BLMszA=; b=k26gwy3dwwIlQyBP4N54gjqPfnfyayfHxU0JZPsEVY6lWzaQ34iMd6jTvkatBxRCs6Y6HK 8UfNH2RVTEz7qqDg== Received: from quack2.suse.cz (unknown [10.100.224.230]) by relay2.suse.de (Postfix) with ESMTP id 6FB26A3BBB; Tue, 13 Jul 2021 12:35:48 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 4DCC31E0BBC; Tue, 13 Jul 2021 14:35:48 +0200 (CEST) Date: Tue, 13 Jul 2021 14:35:48 +0200 From: Jan Kara To: Christoph Hellwig Message-ID: <20210713123548.GA24271@quack2.suse.cz> References: <20210712163901.29514-1-jack@suse.cz> <20210712165609.13215-3-jack@suse.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Headers-End: 1m3Hdm-0001yw-CT Subject: Re: [f2fs-dev] [PATCH 03/14] mm: Protect operations adding pages to page cache with invalidate_lock X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-cifs@vger.kernel.org, Jan Kara , "Darrick J. Wong" , Dave Chinner , Matthew Wilcox , linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ted Tso , ceph-devel@vger.kernel.org, linux-ext4@vger.kernel.org, Christoph Hellwig Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Tue 13-07-21 07:25:05, Christoph Hellwig wrote: > Still looks good. That being said the additional conditional locking in > filemap_fault makes it fall over the readbility cliff for me. Something > like this on top of your series would help: Yeah, that's better. Applied, thanks. Honza > > diff --git a/mm/filemap.c b/mm/filemap.c > index fd3f94d36c49..0fad08331cf4 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -3040,21 +3040,23 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) > * Do we have something in the page cache already? > */ > page = find_get_page(mapping, offset); > - if (likely(page) && !(vmf->flags & FAULT_FLAG_TRIED)) { > + if (likely(page)) { > /* > - * We found the page, so try async readahead before > - * waiting for the lock. > + * We found the page, so try async readahead before waiting for > + * the lock. > */ > - fpin = do_async_mmap_readahead(vmf, page); > - } else if (!page) { > + if (!(vmf->flags & FAULT_FLAG_TRIED)) > + fpin = do_async_mmap_readahead(vmf, page); > + if (unlikely(!PageUptodate(page))) { > + filemap_invalidate_lock_shared(mapping); > + mapping_locked = true; > + } > + } else { > /* No page in the page cache at all */ > count_vm_event(PGMAJFAULT); > count_memcg_event_mm(vmf->vma->vm_mm, PGMAJFAULT); > ret = VM_FAULT_MAJOR; > fpin = do_sync_mmap_readahead(vmf); > - } > - > - if (!page) { > retry_find: > /* > * See comment in filemap_create_page() why we need > @@ -3073,9 +3075,6 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) > filemap_invalidate_unlock_shared(mapping); > return VM_FAULT_OOM; > } > - } else if (unlikely(!PageUptodate(page))) { > - filemap_invalidate_lock_shared(mapping); > - mapping_locked = true; > } > > if (!lock_page_maybe_drop_mmap(vmf, page, &fpin)) -- Jan Kara SUSE Labs, CR _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel