Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp786865lqg; Sat, 2 Mar 2024 01:37:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXtNKLxpZMsxcOmacxbRzxeaQwKGmNsa7qWRvW3W4ZOPe8gzvIzGkP6mSqWnNKNPg7iJ+2FPzXKPUMX0GNNR85tr5yAhjId7eN7W5Gv/g== X-Google-Smtp-Source: AGHT+IHLHLwK/aKSA7TD/v+IV28jbEr96j1TMk/4PBMR5f6enLyK2A/Q2rjhOsc2Vr7AHtmZHK+5 X-Received: by 2002:a17:906:e28e:b0:a44:e6fa:269 with SMTP id gg14-20020a170906e28e00b00a44e6fa0269mr393650ejb.64.1709372256445; Sat, 02 Mar 2024 01:37:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709372256; cv=pass; d=google.com; s=arc-20160816; b=vQLLZ55bAKO6vHpkhFqZzHT07y6ZzburDqZFGd7w5ASjQU7W9ja9i35xXw7nBZg2wl n91CkxXeAeF8GI6/GY69fpJg9o5Z86LfhXzkySEdioYH4MVrQEznVq4JQU/LvSdWPifE sCX+pKDbNOOZyy61YCYA7cehJVrE8zplyloa2wSa95TcA09mmnFSNY9E9J+98hGMj3c7 yDRJl8IL+HoicouXf6Ya4Q8Z5ZW6YV3YSi8dOkxPO1B4ry/YueKQonSTyUMOr6rlt+A5 KGJoZnM3rpCfZg3ie24jDdHgTZWNLGOAoCot/latySPHvZgy/5hLdINodgOMDmXJX0GW LrPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=+xN3EBweyd5sTbssjOEWo3exwDf/vBhxgBb7M9LhCFY=; fh=OvHfpCuCg9nEJ0PcxEkrJ2cAnfV9QbcLL6h0mDN/CjA=; b=zPiKTvLgV86LgsPjL4B/S/mADTTU/wgspEV/SujcV21k0gqprQcZwNzAuuTwRBpBPI NGo0Y7wRYnOcBUQCH/2iXj0g5Ma7ZPUKjA831GDSmJ4lVPgAeCm+B/RRgAXkG5yVR4mn mkYmNUQvF1rmZ6AWynySlt4ILh6T6thhjtom64ZUWuClbzGSEjHQ5SJmDbU49HzBb+L1 IK5++CpXgN35mUt/hANmDxkPWy8926r4F7Wty43T3BXVi07Z3y87/qHZ8AfLcGu7E3VB a6NbC3aqOHVbesQ8fPUHhhittVhcXfcQ0Kt7+eQQ+OxZLRUB54Ts3PTuK0KfAWXNWxgH MM4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-89399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89399-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id do21-20020a170906c11500b00a433006f817si2352399ejc.877.2024.03.02.01.37.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 01:37:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-89399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89399-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2B22E1F21E2D for ; Sat, 2 Mar 2024 09:37:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D5ED15EB0; Sat, 2 Mar 2024 09:37:23 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00E25168BD; Sat, 2 Mar 2024 09:37:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709372243; cv=none; b=ay+sf4gXQzDgzoAChcsjEdyG4G+9vrsXGdzkKdNNQgPvu/NC1PT+Y43cgcimCn3pgl8tQ6p5u4LIYWVZlctomoIE7fOgtdhc0A/Twf2HYW4PZzpetc2kD2HNdFw8YULo9v/UB3Kw7/sd9SXWP+nWq5bh75VPXFJpleylbuFk358= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709372243; c=relaxed/simple; bh=8kiw5+UWs4a9+DdGKdL4oMotwww+LKy0HwEZtFqYFjk=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=fgcLco1fYD7WvY4YxgQUNFK0LR6MO5nnBzvcO1hfqB5bo8n0ontevk+iih/HjAFm2FZFNU64fbVCejfnzag9zaavgoKks8gMH1oZXENW4QQ9L5rRx4lFOy9h1t4+dBhhOppiPy4NtDOl0wOJHI1BxdIY9CdCTiveTVmdr03tqfo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Tn0Gx2Hwtz1FLPY; Sat, 2 Mar 2024 17:37:13 +0800 (CST) Received: from kwepemm600017.china.huawei.com (unknown [7.193.23.234]) by mail.maildlp.com (Postfix) with ESMTPS id 0DE711A016B; Sat, 2 Mar 2024 17:37:17 +0800 (CST) Received: from [10.174.179.234] (10.174.179.234) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Sat, 2 Mar 2024 17:37:15 +0800 Message-ID: Date: Sat, 2 Mar 2024 17:37:15 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [bug report] dead loop in generic_perform_write() //Re: [PATCH v7 07/12] iov_iter: Convert iterate*() to inline funcs To: Linus Torvalds , Al Viro CC: David Howells , Jens Axboe , Christoph Hellwig , Christian Brauner , David Laight , Matthew Wilcox , Jeff Layton , , , , , , Kefeng Wang References: <20230925120309.1731676-1-dhowells@redhat.com> <20230925120309.1731676-8-dhowells@redhat.com> <4e80924d-9c85-f13a-722a-6a5d2b1c225a@huawei.com> From: Tong Tiangen In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600017.china.huawei.com (7.193.23.234) 在 2024/3/2 10:59, Linus Torvalds 写道: > On Thu, 29 Feb 2024 at 09:32, Linus Torvalds > wrote: >> >> One option might be to make a failed memcpy_from_iter_mc() set another >> flag in the iter, and then make fault_in_iov_iter_readable() test that >> flag and return 'len' if that flag is set. >> >> Something like that (wild handwaving) should get the right error handling. >> >> The simpler alternative is maybe something like the attached. >> COMPLETELY UNTESTED. Maybe I've confused myself with all the different >> indiraction mazes in the iov_iter code. > > Actually, I think the right model is to get rid of that horrendous > .copy_mc field entirely. > > We only have one single place that uses it - that nasty core dumping > code. And that code is *not* performance critical. > > And not only isn't it performance-critical, it already does all the > core dumping one page at a time because it doesn't want to write pages > that were never mapped into user space. > > So what we can do is > > (a) make the core dumping code *copy* the page to a good location > with copy_mc_to_kernel() first > > (b) remove this horrendous .copy_mc crap entirely from iov_iter I think this solution has two impacts: 1. Although it is not a performance-critical path, the CPU usage may be affected by one more memory copy in some large-memory applications. 2. If a hardware memory error occurs in "good location" and the ".copy_mc" is removed, the kernel will panic. I would prefer to use the previous solution(modify the implementation of memcpy_from_iter_mc()). Thanks, Tong. > > This is slightly complicated by the fact that copy_mc_to_kernel() may > not even exist, and architectures that don't have it don't want the > silly extra copy. So we need to abstract the "copy to temporary page" > code a bit. But that's probably a good thing anyway in that it forces > us to have nice interfaces. > > End result: something like the attached. > > AGAIN: THIS IS ENTIRELY UNTESTED. > > But hey, so was clearly all the .copy_mc code too that this removes, so... > > Linus