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 74793C43219 for ; Tue, 14 Dec 2021 10:03:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232793AbhLNKDi (ORCPT ); Tue, 14 Dec 2021 05:03:38 -0500 Received: from mail.loongson.cn ([114.242.206.163]:33166 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229550AbhLNKDh (ORCPT ); Tue, 14 Dec 2021 05:03:37 -0500 Received: from [10.130.0.135] (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx_Nzfa7hhAZYAAA--.3224S3; Tue, 14 Dec 2021 18:03:13 +0800 (CST) Subject: Re: [PATCH v2 0/2] kdump: simplify code To: Matthew Wilcox , David Laight References: <1639193588-7027-1-git-send-email-yangtiezhu@loongson.cn> <0c5cb37139af4f3e85cc2c5115d7d006@AcuMS.aculab.com> Cc: Dave Young , Baoquan He , Vivek Goyal , Andrew Morton , "linux-arm-kernel@lists.infradead.org" , "linux-ia64@vger.kernel.org" , "linux-mips@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-riscv@lists.infradead.org" , "linux-sh@vger.kernel.org" , "x86@kernel.org" , "linux-fsdevel@vger.kernel.org" , "kexec@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Xuefeng Li , Christophe Leroy From: Tiezhu Yang Message-ID: <36440c0f-8b8a-c401-684f-6f54ce9c061e@loongson.cn> Date: Tue, 14 Dec 2021 18:03:11 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf9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daVFxhVjvjDU0xZFpf9x0JU6c_fUUUUU= X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/13/2021 10:43 PM, Matthew Wilcox wrote: > On Mon, Dec 13, 2021 at 08:30:33AM +0000, David Laight wrote: >> From: Matthew Wilcox >>> Sent: 12 December 2021 11:48 >>> >>> On Sat, Dec 11, 2021 at 05:53:46PM +0000, David Laight wrote: >>>> From: Tiezhu Yang >>>>> Sent: 11 December 2021 03:33 >>>>> >>>>> v2: >>>>> -- add copy_to_user_or_kernel() in lib/usercopy.c >>>>> -- define userbuf as bool type >>>> >>>> Instead of having a flag to indicate whether the buffer is user or kernel, >>>> would it be better to have two separate buffer pointers. >>>> One for a user space buffer, the other for a kernel space buffer. >>>> Exactly one of the buffers should always be NULL. >>> >>> No. You should be using an iov_iter instead. See >>> https://lore.kernel.org/all/Ya4bdB0UBJCZhUSo@casper.infradead.org/ >>> for a start on this. >> >> iov_iter gets horribly expensive... > > Oh, right. Reading the kcore is a high-performance path, my mistake. > Hi, Thank you for your discussions. The intention of this patchset is to simplify the related code with no functional changes and no side effects. At this moment, if you are OK, I will send v3 used with inline function copy_to_user_or_kernel() to keep it simple, maybe other more changes can be done in the future if no any side effect. The v3 will contain the following three patches to make the changes more clear: kdump: vmcore: remove copy_to() and add copy_to_user_or_kernel() kdump: crashdump: use copy_to_user_or_kernel() to simplify code kdump: vmcore: crashdump: make variable type of userbuf as bool