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 DE5ADC433F5 for ; Mon, 29 Nov 2021 23:14:10 +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=nHmJEPJmV6CxRj6VnxarygdUZwCL5J31uhZ6z3devqw=; b=GSy6ndjCwhQQ7m mY0enHsyKLB1mU/g6gRmkE0fxZI+wUXONjFONF9fqkXi71+6J/S7mIlAF3SR+c+u6iB/imj1UEarC i4FTkEseIt4cpEOwi7KInrYSNjzhKexDPUgTkh7uC36V+eUzG2zuYhB79N7bEduo3ZcLWvoAHtIPQ B7jQKUqftmn6i2ux0lkofGhL5MulDdA58ufiTApYYrPxf2HHyy/I88je7P4bFAG3VWWa38ebp9RmQ 8+jO5V06zqpexCuLBksG7ZuftEXTg5hVn1NykPUv5xLMwaGw+XF29kF0W2S2Hd64ydNms0kYo7xZ2 r7runcuLshRmXx2zGPwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrppO-0033Z6-5W; Mon, 29 Nov 2021 23:12:54 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrppJ-0033Xs-TK for linux-arm-kernel@lists.infradead.org; Mon, 29 Nov 2021 23:12:51 +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 sin.source.kernel.org (Postfix) with ESMTPS id 4B30DCE16E6; Mon, 29 Nov 2021 23:12:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 665C2C53FAD; Mon, 29 Nov 2021 23:12:44 +0000 (UTC) Date: Mon, 29 Nov 2021 23:12:41 +0000 From: Catalin Marinas To: Linus Torvalds Cc: Andreas Gruenbacher , Matthew Wilcox , Josef Bacik , David Sterba , Al Viro , Andrew Morton , Will Deacon , linux-fsdevel , LKML , 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: <20211127123958.588350-1-agruenba@redhat.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-20211129_151250_164139_71CCAC9C X-CRM114-Status: GOOD ( 17.07 ) 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 Mon, Nov 29, 2021 at 01:53:01PM -0800, Linus Torvalds wrote: > On Mon, Nov 29, 2021 at 12:56 PM Catalin Marinas > wrote: > > I think that would be useful, though it doesn't solve the potential > > livelock with sub-page faults. > > I was assuming we'd just do the sub-page faults. > > In fact, I was assuming we'd basically just replace all the PAGE_ALIGN > and PAGE_SIZE with SUBPAGE_{ALIGN,SIZE}, together with something like > > if (size > PAGE_SIZE) > size = PAGE_SIZE; > > to limit that size thing (or possibly make that "min size" be a > parameter, so that people who have things like that "I need at least > this initial structure to be copied" issue can document their minimum > size needs). Ah, so fault_in_writeable() would never fault in the whole range (if too large). When copy_to_user() goes beyond the faulted in range, it may fail and we go back to fault in a bit more of the range. A copy loop would be equivalent to: fault_addr = ubuf; end = ubuf + size; while (1) { if (fault_in_writeable(fault_addr, min(PAGE_SIZE, end - fault_addr))) break; left = copy_to_user(ubuf, kbuf, size); if (!left) break; fault_addr = end - left; } That should work. I'll think about it tomorrow, getting late over here. (I may still keep the sub-page probing in the arch code, see my earlier exchanges with Andreas) -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel