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 E49E3C433EF for ; Mon, 29 Nov 2021 19:33:27 +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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MPtQebGBHaExMzfEdhjpc3vich7RNnHZlDpFdvDoOM0=; b=F0kMJRCUzbeXoN Vd2SQHxRtBQ6rVfb1u4jDzKyMbpnb/QbGS9JiGV2BjmBflDfvaRVw2CMltWQKErG5d37Qama6/W8i hEWslaJTvE1swzfr+4DtRz19ydo1Se/R0aCDhuo7VJOf7snMYx7ap+hXqaUdRZMu2bdTyyV+YdLYz 97xdOlmQc27ok5ov3IhdhBjN6pImnlEbm5R7jQ3DrSlbhEbUBn5xKvZDIyNTXBTy34nIFXBzWIPCl sfNEiC6qoFtijoF8rpemK2AbyuqMAP6IXkKPpIUJt/7kYfRr3dVVa3ffjxAB8N9cTTyKQlNdzIXIl xQ87OcJomqbBAbCiDLSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrmNe-0028oh-8s; Mon, 29 Nov 2021 19:32:02 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrmNZ-0028ng-8f for linux-arm-kernel@lists.infradead.org; Mon, 29 Nov 2021 19:31:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638214316; h=from:from:reply-to:subject:subject: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=yaRvpoInOnEEHMP7nyqwnXQsh6SAlooVZxGGKWanykI=; b=g3ysvnMWMSLafJrQ7CpXnsCzTsfuzBBOdlwYROYS9WlO4WAq3UWd/I/b4fyCra5SUkAhs8 r+kXVgyWxNsNh6cZqyddTBFEs/uCLKR6HmIKhVQBve0YEcmh9wQDC2gewIT2EcUOVDPTdL wWnn8bYtqVG/VwWVXKBVjiIbVTgvBN0= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-224-xxCT7NB1P3eGrXBV4BfqaA-1; Mon, 29 Nov 2021 14:31:54 -0500 X-MC-Unique: xxCT7NB1P3eGrXBV4BfqaA-1 Received: by mail-wm1-f72.google.com with SMTP id g11-20020a1c200b000000b003320d092d08so9131287wmg.9 for ; Mon, 29 Nov 2021 11:31:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yaRvpoInOnEEHMP7nyqwnXQsh6SAlooVZxGGKWanykI=; b=TPsxcSvpN8+CPSHGq4FbfoObf4NBEY8D/8N0UCvxwTJsZnUI8ZToKUqCinbHoXBucW K553wqaHqoVCCPBwB7T+379FXWsMF0yUtty3Wkq/J5EVBD8KfgLcFdBZGMDJrSXRS6N7 e15MSXcH5S1tmIDVJ9uFwiwCxBeQ5cUOtRMkpOMj+ifrO+Exgz+6a6zDtEK3b7FXbgsu Q/GlGImZ+PKoBaDyb9xBHyuFr3nUL56LAH0D8RJtmLFhJ92v/M8a3hRp02l53wwE4urW jzjG97nfuvk0PtXuwoAckYJv2XtZLe6nOVHxeG/GoaK6J5eoDMXMPQPSERUxZuZVSFsj AOJA== X-Gm-Message-State: AOAM531mKb8xz+dUTD0VBLyZGFOX24EQTgO5oiq3gp6BYgRG16L0p1bj /Gy1aFDw94ExNzQBONmMupat/FzM+GzGGq2XtzCeK76hlmjG9SYqIfTXw2wP4wlUmMpNRmH6rUz eC52XRPcUXYkL+0q4kMvHSiY1KOskRPrYXdDjmyk6BeMx6kDHJ3E= X-Received: by 2002:adf:f749:: with SMTP id z9mr36910293wrp.379.1638214311588; Mon, 29 Nov 2021 11:31:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSv2WybHRedA4NST/0L7m41HCQb6LRVF5wHW9P5FzzrZgkSDOaniNFjz8BjqBW06bNnR5BfRT4OlQsVo6M068= X-Received: by 2002:adf:f749:: with SMTP id z9mr36910269wrp.379.1638214311399; Mon, 29 Nov 2021 11:31:51 -0800 (PST) MIME-Version: 1.0 References: <20211124192024.2408218-1-catalin.marinas@arm.com> <20211124192024.2408218-4-catalin.marinas@arm.com> <20211127123958.588350-1-agruenba@redhat.com> In-Reply-To: From: Andreas Gruenbacher Date: Mon, 29 Nov 2021 20:31:39 +0100 Message-ID: Subject: Re: [PATCH 3/3] btrfs: Avoid live-lock in search_ioctl() on hardware with sub-page faults To: Linus Torvalds Cc: Catalin Marinas , Matthew Wilcox , Josef Bacik , David Sterba , Al Viro , Andrew Morton , Will Deacon , linux-fsdevel , LKML , Linux ARM , linux-btrfs Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=agruenba@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211129_113157_387943_C59268AB X-CRM114-Status: GOOD ( 31.61 ) 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 7:41 PM Linus Torvalds wrote: > On Mon, Nov 29, 2021 at 7:36 AM Catalin Marinas wrote: > > > > That's what this series does when it probes the whole range in > > fault_in_writeable(). The main reason was that it's more efficient to do > > a read than a write on a large range (the latter dirtying the cache > > lines). > > The more this thread goes on, the more I'm starting to think that we > should just make "fault_in_writable()" (and readable, of course) only > really work on the beginning of the area. > > Not just for the finer-granularity pointer color probing, but for the > page probing too. > > I'm looking at our current fault_in_writeable(), and I'm going > > (a) it uses __put_user() without range checks, which is really not great > > (b) it looks like a disaster from another standpoint: essentially > user-controlled loop size with no limit checking, no preemption, and > no check for fatal signals. > > Now, (a) should be fixed with a access_ok() or similar. > > And (b) can easily be fixed multiple ways, with one option simply just > being adding a can_resched() call and checking for fatal signals. > > But faulting in the whole region is actually fundamentally wrong in > low-memory situations - the beginning of the region might be swapped > out by the time we get to the end. That's unlikely to be a problem in > real life, but it's an example of how it's simply not conceptually > sensible. > > So I do wonder why we don't just say "fault_in_writable will fault in > _at_most_ X bytes", and simply limit the actual fault-in size to > something reasonable. > > That solves _all_ the problems. It solves the lack of preemption and > fatal signals (by virtue of just limiting the amount of work we do). > It solves the low memory situation. And it solves the "excessive dirty > cachelines" case too. > > Of course, we want to have some minimum bytes we fault in too, but > that minimum range might well be "we guarantee at least a full page > worth of data" (and in practice make it a couple of pages). > > It's not like fault_in_writeable() avoids page faults or anything like > that - it just moves them around. So there's really very little reason > to fault in a large range, and there are multiple reasons _not_ to do > it. > > Hmm? This would mean that we could get rid of gfs2's should_fault_in_pages() logic, which is based on what's in btrfs_buffered_write(). Andreas > > Linus > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel