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 2A5EFC433EF for ; Mon, 20 Dec 2021 08:10:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237852AbhLTIKz (ORCPT ); Mon, 20 Dec 2021 03:10:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20905 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237849AbhLTIKy (ORCPT ); Mon, 20 Dec 2021 03:10:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639987853; 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=zxVKzNF0cgW394JRMHP12IXVI+3E1hxn9KxUG4k3b/M=; b=AYjjeUvF5YW+wuhj69kpnJdEGvdN93qtcpQEpJnHCTE4Yfh7KoLT4CDInYm57xrxj7vSHf Hu32E0HhpR23Z1aKZyP5VaXeIGz8N5dk0h0IvC1UoXquJ+H0S0bMWBjfw6PAB2PuVWhmYh Jhy+uQYCmZFTD0x5gTQf31XQwtCYt0Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-18-qtsvmVCYMnOrSGlbLXOTyg-1; Mon, 20 Dec 2021 03:10:50 -0500 X-MC-Unique: qtsvmVCYMnOrSGlbLXOTyg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A9D48101AFA7; Mon, 20 Dec 2021 08:10:48 +0000 (UTC) Received: from localhost (ovpn-12-142.pek2.redhat.com [10.72.12.142]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C158A6107F; Mon, 20 Dec 2021 08:10:47 +0000 (UTC) Date: Mon, 20 Dec 2021 16:10:45 +0800 From: Baoquan He To: "Matthew Wilcox (Oracle)" Cc: Vivek Goyal , Dave Young , akpm@linux-foundation.org, kexec@lists.infradead.org, Tiezhu Yang , linux-kernel@vger.kernel.org, Amit Daniel Kachhap , Christoph Hellwig , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v3 1/3] vmcore: Convert copy_oldmem_page() to take an iov_iter Message-ID: <20211220081045.GC31681@MiWiFi-R3L-srv> References: <20211213143927.3069508-1-willy@infradead.org> <20211213143927.3069508-2-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211213143927.3069508-2-willy@infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/13/21 at 02:39pm, Matthew Wilcox (Oracle) wrote: > Instead of passing in a 'buf' and 'userbuf' argument, pass in an iov_iter. > s390 needs more work to pass the iov_iter down further, or refactor, > but I'd be more comfortable if someone who can test on s390 did that work. > > It's more convenient to convert the whole of read_from_oldmem() to > take an iov_iter at the same time, so rename it to read_from_oldmem_iter() > and add a temporary read_from_oldmem() wrapper that creates an iov_iter. > > Signed-off-by: Matthew Wilcox (Oracle) Thanks for making this to do an awesome clean up. This one looks good to me. Acked-by: Baoquan He ...... > -/** > - * copy_oldmem_page() - copy one page from old kernel memory > - * @pfn: page frame number to be copied > - * @buf: buffer where the copied page is placed > - * @csize: number of bytes to copy > - * @offset: offset in bytes into the page > - * @userbuf: if set, @buf is int he user address space > - * > - * This function copies one page from old kernel memory into buffer pointed by > - * @buf. If @buf is in userspace, set @userbuf to %1. Returns number of bytes > - * copied or negative error in case of failure. > - */ > -ssize_t copy_oldmem_page(unsigned long pfn, char *buf, > - size_t csize, unsigned long offset, > - int userbuf) > +ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn, > + size_t csize, unsigned long offset) ^^^^^^ I am curious why this parameter is called 'csize', but not 'size' directly. This is not related to this patch, it's an old naming. > { > void *vaddr; > > @@ -40,14 +28,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf, > if (!vaddr) > return -ENOMEM; > > - if (userbuf) { > - if (copy_to_user(buf, vaddr + offset, csize)) { > - iounmap(vaddr); > - return -EFAULT; > - } > - } else { > - memcpy(buf, vaddr + offset, csize); > - } > + csize = copy_to_iter(vaddr + offset, csize, iter); > > iounmap(vaddr); > return csize;