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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EFFFC433EF for ; Wed, 6 Apr 2022 21:31:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232761AbiDFVct (ORCPT ); Wed, 6 Apr 2022 17:32:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236247AbiDFVcg (ORCPT ); Wed, 6 Apr 2022 17:32:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 601A0347993; Wed, 6 Apr 2022 13:40:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 041F76123F; Wed, 6 Apr 2022 20:40:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2959AC385A1; Wed, 6 Apr 2022 20:40:27 +0000 (UTC) Date: Wed, 6 Apr 2022 21:40:23 +0100 From: Catalin Marinas To: Linus Torvalds , Andreas Gruenbacher , Josef Bacik Cc: Al Viro , Andrew Morton , Chris Mason , David Sterba , Will Deacon , linux-fsdevel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/3] btrfs: Avoid live-lock in search_ioctl() on hardware with sub-page faults Message-ID: References: <20220406180922.1522433-1-catalin.marinas@arm.com> <20220406180922.1522433-4-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220406180922.1522433-4-catalin.marinas@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Wed, Apr 06, 2022 at 07:09:22PM +0100, Catalin Marinas wrote: > diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c > index 238cee5b5254..d49e8254f823 100644 > --- a/fs/btrfs/ioctl.c > +++ b/fs/btrfs/ioctl.c > @@ -2556,8 +2556,13 @@ static noinline int search_ioctl(struct inode *inode, > key.offset = sk->min_offset; > > while (1) { > + size_t len = *buf_size - sk_offset; > ret = -EFAULT; > - if (fault_in_writeable(ubuf + sk_offset, *buf_size - sk_offset)) > + /* > + * Ensure that the whole user buffer is faulted in at sub-page > + * granularity, otherwise the loop may live-lock. > + */ > + if (fault_in_subpage_writeable(ubuf + sk_offset, len)) > break; This doesn't need a new 'len' variable. It's a left-over from the v2 where fault_in_writeable() took the size and a min_size argument, both being 'len'. -- Catalin 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BC34C433F5 for ; Wed, 6 Apr 2022 20:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=78lAv4dmjKOptbJlcQXpQFVrOvELQN22iBt5gkToV8A=; b=wl1mN/7M81Qi4g 2w07/GJYR2CkYIB0zBRzvELNXilwWDNLSY8t7ixrhN9R6ESok/VTvZxyiok44FYBADaPB41uxY42N Nj5C1Er566TfShi921J2u/FUnOYe3/rgBUdFyngZXpo8kwqR01RVblf/g8pAiDHE3JzHvbFfZAG72 1I9KK8uj3p747KVgjOJn1pvWd7gZf3ufP3H6M8LdQwG71C2utsUnF+2PR7EIJpkeI+hjPR3I5bKhu IEQeu0t8Db34n3CyLQiFXhUC/hBP075un9i9Hy0IelPaLd5bqVHGGAR8Q+IO/cyfYjfva6qbB4NWp Nb7Ub2AakB5yJ/V9s93w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncCS9-007uBT-7n; Wed, 06 Apr 2022 20:40:33 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncCS6-007uAm-TK for linux-arm-kernel@lists.infradead.org; Wed, 06 Apr 2022 20:40:32 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 06C5361748; Wed, 6 Apr 2022 20:40:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2959AC385A1; Wed, 6 Apr 2022 20:40:27 +0000 (UTC) Date: Wed, 6 Apr 2022 21:40:23 +0100 From: Catalin Marinas To: Linus Torvalds , Andreas Gruenbacher , Josef Bacik Cc: Al Viro , Andrew Morton , Chris Mason , David Sterba , Will Deacon , linux-fsdevel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/3] btrfs: Avoid live-lock in search_ioctl() on hardware with sub-page faults Message-ID: References: <20220406180922.1522433-1-catalin.marinas@arm.com> <20220406180922.1522433-4-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220406180922.1522433-4-catalin.marinas@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_134031_029556_CDDE2905 X-CRM114-Status: GOOD ( 15.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Apr 06, 2022 at 07:09:22PM +0100, Catalin Marinas wrote: > diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c > index 238cee5b5254..d49e8254f823 100644 > --- a/fs/btrfs/ioctl.c > +++ b/fs/btrfs/ioctl.c > @@ -2556,8 +2556,13 @@ static noinline int search_ioctl(struct inode *inode, > key.offset = sk->min_offset; > > while (1) { > + size_t len = *buf_size - sk_offset; > ret = -EFAULT; > - if (fault_in_writeable(ubuf + sk_offset, *buf_size - sk_offset)) > + /* > + * Ensure that the whole user buffer is faulted in at sub-page > + * granularity, otherwise the loop may live-lock. > + */ > + if (fault_in_subpage_writeable(ubuf + sk_offset, len)) > break; This doesn't need a new 'len' variable. It's a left-over from the v2 where fault_in_writeable() took the size and a min_size argument, both being 'len'. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel