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 D5EDDC433F5 for ; Thu, 25 Nov 2021 11:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234647AbhKYLP7 (ORCPT ); Thu, 25 Nov 2021 06:15:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:41828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbhKYLN7 (ORCPT ); Thu, 25 Nov 2021 06:13:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C807360230; Thu, 25 Nov 2021 11:10:45 +0000 (UTC) Date: Thu, 25 Nov 2021 11:10:43 +0000 From: Catalin Marinas To: Linus Torvalds Cc: Matthew Wilcox , Josef Bacik , David Sterba , Andreas Gruenbacher , Al Viro , Andrew Morton , Will Deacon , linux-fsdevel , Linux Kernel Mailing List , Linux ARM , linux-btrfs Subject: Re: [PATCH 3/3] btrfs: Avoid live-lock in search_ioctl() on hardware with sub-page faults Message-ID: References: <20211124192024.2408218-1-catalin.marinas@arm.com> <20211124192024.2408218-4-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Wed, Nov 24, 2021 at 03:00:00PM -0800, Linus Torvalds wrote: > On Wed, Nov 24, 2021 at 12:04 PM Matthew Wilcox wrote: > > (where __copy_to_user_nofault() is a new function that does exactly what > > copy_to_user_nofault() does, but returns the number of bytes copied) > > If we want the "how many bytes" part, then we should just make > copy_to_user_nofault() have the same semantics as a plain > copy_to_user(). > > IOW, change it to return "number of bytes not copied". > > Looking at the current uses, such a change would be trivial. The only > case that wants a 0/-EFAULT error is the bpf_probe_write_user(), > everybody else already just wants "zero for success", so changing > copy_to_user_nofault() would be trivial. I agree, if we want the number of byte not copied, we should just change copy_{to,from}_user_nofault() and their callers (I can count three each). For this specific btrfs case, if we want go with tuning the offset based on the fault address, we'd need copy_to_user_nofault() (or a new function) to be exact. IOW, fall back to byte-at-a-time copy until it hits the real faulting address. -- 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 CF912C433F5 for ; Thu, 25 Nov 2021 11:14:19 +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=NKrJP9x3dvtjcG94oEjamAA4+aziq81+xib4/wY95qQ=; b=i5KLuw2zesbml/ S+CPYPTecY7ef9cSq2r8fVtz88MsGNQiKQYFfYSYVT5HbmhEAZ7/ZqKs4xsxbnXvRNZzZHoiX69vy X+2U6kVhVLY/PtYzmiB/VnKFxNcR66Q8sE86kZSRf+MYPPXR2UkoXOLh8MPWbq+AyPeUvqwW60W22 OmtrD/7tzy6pXbWr6hWpfVQ+L+nU7XDenVLJ8GOYNUVqn5XBohzqvr3cnFHdyi14+HVMZEMOHwbsC Ab4HhwfD71jySfnTGWPmZkg3hEmIuGu9WwrgBd3tSqv033NchjKTrM+7+pOu0FgIKSs+IzFVTlFsf zMfqwxNS9ck6QkJ+ks+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqCg2-007CDa-Sx; Thu, 25 Nov 2021 11:12:31 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqCeO-007BE4-5T for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 11:10:49 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id C807360230; Thu, 25 Nov 2021 11:10:45 +0000 (UTC) Date: Thu, 25 Nov 2021 11:10:43 +0000 From: Catalin Marinas To: Linus Torvalds Cc: Matthew Wilcox , Josef Bacik , David Sterba , Andreas Gruenbacher , Al Viro , Andrew Morton , Will Deacon , linux-fsdevel , Linux Kernel Mailing List , Linux ARM , linux-btrfs Subject: Re: [PATCH 3/3] btrfs: Avoid live-lock in search_ioctl() on hardware with sub-page faults Message-ID: References: <20211124192024.2408218-1-catalin.marinas@arm.com> <20211124192024.2408218-4-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211125_031048_258897_D0EB9F8F X-CRM114-Status: GOOD ( 15.15 ) 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, Nov 24, 2021 at 03:00:00PM -0800, Linus Torvalds wrote: > On Wed, Nov 24, 2021 at 12:04 PM Matthew Wilcox wrote: > > (where __copy_to_user_nofault() is a new function that does exactly what > > copy_to_user_nofault() does, but returns the number of bytes copied) > > If we want the "how many bytes" part, then we should just make > copy_to_user_nofault() have the same semantics as a plain > copy_to_user(). > > IOW, change it to return "number of bytes not copied". > > Looking at the current uses, such a change would be trivial. The only > case that wants a 0/-EFAULT error is the bpf_probe_write_user(), > everybody else already just wants "zero for success", so changing > copy_to_user_nofault() would be trivial. I agree, if we want the number of byte not copied, we should just change copy_{to,from}_user_nofault() and their callers (I can count three each). For this specific btrfs case, if we want go with tuning the offset based on the fault address, we'd need copy_to_user_nofault() (or a new function) to be exact. IOW, fall back to byte-at-a-time copy until it hits the real faulting address. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel