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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1858DC54798 for ; Sat, 2 Mar 2024 09:37:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 344896B009C; Sat, 2 Mar 2024 04:37:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F3366B009D; Sat, 2 Mar 2024 04:37:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BAC06B009F; Sat, 2 Mar 2024 04:37:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0A1206B009C for ; Sat, 2 Mar 2024 04:37:25 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8FEA680520 for ; Sat, 2 Mar 2024 09:37:24 +0000 (UTC) X-FDA: 81851596008.25.A24C7EF Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf06.hostedemail.com (Postfix) with ESMTP id 8D4D1180003 for ; Sat, 2 Mar 2024 09:37:21 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709372242; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+xN3EBweyd5sTbssjOEWo3exwDf/vBhxgBb7M9LhCFY=; b=bpF677iKJV/41PJgGMPybMDazUUnhoIBGC7oz3HnrSa+yr5h4dRjHPILkWNK2Ze4OYSf+U s14Hv0kUQf2gBUfRYxnB9DvO6z62dawUlduZ52qz32+fbbCxwcBYXm1+6uRHRCoegoHnH2 cyzk29UEdTRV1F3+NVkKOksEjquIyZM= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709372242; a=rsa-sha256; cv=none; b=QjyAFzCrzkOvIlX+hO1W1cDHRwY5flXGdau+JjBIFPuKYR5sw5wpbulO4FYgJrmXu1PIKU CoVnPl04DId/E/XW3M/aML8OUGDhCqVi8fp8iWENJxiHGCeswlPx9u5FhcD1dN8c3JWG5l e7KGwT6pWLeptlLTH85qH6EXH+Z8Mk4= 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 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-Originating-IP: [10.174.179.234] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600017.china.huawei.com (7.193.23.234) X-Rspam-User: X-Stat-Signature: poucbn87ax3676wiyoea3gefgmxotfbh X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8D4D1180003 X-HE-Tag: 1709372241-382509 X-HE-Meta: U2FsdGVkX18uKL2wzAa7a2uGZeJll9xyMH+7BExPJIeXzEXK4t3Wix5dWxHP1lS/zotBNObVmVWDde2UjFMNCnhvvGPuUQzHE0PetzufkTFeVV5eE82xOrEHvfu3gRScCICo3NFesrHwVMFzenhmfwzcCSnKlJzIm5VoNrmpLWMp4AQVl3Ys+IWzlbd+zYS5xvoQqJ0FSHKfsADhR310V3Oihga3yw+ddZ0crrtwsPAEPpUaX7gKgSutzVB7+YS5XMOuVe8seUZMm5eZkfzFZ1q12/C40V7yB/xYV2nB4pXXbS2gfOJ5dsCYnmZWmqg/QeXXhZBXeNs8+n0ZKfObtMYExSMIMAVg48C5nT6iOCq9VUfsj+f4UGAugztFQ+X7wxdCPOxYx5qu9bSq+wuq2ZpIGzWLynztJgiQo7FyEA+CpozG4qBhM0a9yxRlOl2NLSDZD5vYmawe29bQ6tn45t3H4IbQPRYwMXL3N+z/j1J/2kS0OFrgnOi6hTxKO7oqEsATuA+Be4nrcLVbnU+8h91mca+uUbLVy+ljgeeRwjuQhKk3kQXBBJ+29OAD+HcVuc1CGVXttkmdZXnPjUBtqzBcrIpww821qWRjVLUz1CcRmOYjvPwio7Gqg41HyqpcC5JH81ZZ77qqBppDwbZlUoP8wCJx3FT7ydG1oQvXgEx7g8icmZKveJM1u5TKV33sGyKbMRJUj76H9zTi5E8ehWFJKK5EkVFXOohBXL4rqiQi7w8O4nfFxDflMSzx/UmdX1yqRM4bbi1qOawO06heAwOM84hiTIXZ5n94uB1j3B/BAAuK1LgBZJJT6tPyX9tbV5wFqVR3cvE9Kv79twGZix9i9qY1VFj4 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 在 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