Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp257978pxf; Wed, 24 Mar 2021 04:35:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIVMZpn9Ej6VuY03gxlB1ZYkI5fZLc39iSt1V7UiY4ooXkb8vW+uO/0+RPiDKRYyDG5jFK X-Received: by 2002:a17:906:b752:: with SMTP id fx18mr3279713ejb.128.1616585728407; Wed, 24 Mar 2021 04:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616585728; cv=none; d=google.com; s=arc-20160816; b=XoW/mjbCEN0Y0dQzgnDjx/q0z4qegJ01bPso5PkOSSKb6KSDRwIn50X32f7qKTmKoA TXIo7Obph1Ntu4MWKrAgASVgx4EztoDZ6+wpOzheHMUkw9tfyeOD0CerO4HoO9vZV/d7 4HwaG/CMayGGmVBsdQebj5oj1aufGuOaYzy8MEA0shYQh+8DuYr4ErhUAV0hyXlcBxca +OhU3YFMY+Ok3FZNE7qMmPJXh19MUxCduWKWwEdBVAYBhzu63aTnX1nMZiaZa6DcpmyP Yv347pUf/PZtjAaZ4jynNkfnRXnaGRPvkKV6F9VC9V2EmLUnCGJGgekXtD4c0wy+vMoq Jq8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hLr3oxEF1/9Rhj8o+UPHLCrvFG5XatLxuy2W9STTzPM=; b=PpO7lPX7DiuUY25j/SP5zPv1SbhmdZb8wcb307un84dxMKyXTy9tgDy1B8cDbht7LK bhiXvA6SU6BUjAGMos28cWDsQW2ABHFH1cOqhqhc5if7C+EiZHInoxGA+mAmq6rvsGer u0E8HmJUmGh/0Hm0hgUsNOYiHD3u0NaMQuuS5/9fHZo7BFVeHv+Y8ezBD9LdiiS7TClE gDc0DoFq4oK4WMTHxeVhsvreWd0pbMAldy6WtlXDDnMxw1maXDenLFaKybWN5LfNxfy+ G2zrUGTPko4/Qax2h/8c4Vpvp6MNHpGOsqqoO67hKRfYg5RC0zKpCJMrM5GhoWxsS3TP HuPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GMAgQFoF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si1639155edi.290.2021.03.24.04.35.05; Wed, 24 Mar 2021 04:35:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GMAgQFoF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230018AbhCXKZh (ORCPT + 99 others); Wed, 24 Mar 2021 06:25:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59127 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235714AbhCXKZG (ORCPT ); Wed, 24 Mar 2021 06:25:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616581505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hLr3oxEF1/9Rhj8o+UPHLCrvFG5XatLxuy2W9STTzPM=; b=GMAgQFoFt1RltsFR5cE9jXVsf/FyQDge8FbHrszlKQ8vIagBZwpx5UERAXXVXRhYtF5mmc vSNG110zCifRGXMBjVUvTPllJgZu1tq/OwB2EDDULrf94pinAOGnCP8JFBCcUKMlXo46Jp vujdXIlPxDC8zBKKPHl9kMYeDV601bA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-shSdeTk8O9ahfEpodI8hHw-1; Wed, 24 Mar 2021 06:25:01 -0400 X-MC-Unique: shSdeTk8O9ahfEpodI8hHw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D16DA81621; Wed, 24 Mar 2021 10:24:59 +0000 (UTC) Received: from t480s.redhat.com (ovpn-115-66.ams2.redhat.com [10.36.115.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6ECA10013D7; Wed, 24 Mar 2021 10:24:56 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Linus Torvalds , Greg Kroah-Hartman , Andrew Morton , Hillf Danton , Michal Hocko , Matthew Wilcox , Oleksiy Avramchenko , Steven Rostedt , Minchan Kim , huang ying Subject: [PATCH v1 3/3] mm/vmalloc: remove vwrite() Date: Wed, 24 Mar 2021 11:23:51 +0100 Message-Id: <20210324102351.6932-4-david@redhat.com> In-Reply-To: <20210324102351.6932-1-david@redhat.com> References: <20210324102351.6932-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The last user (/dev/kmem) is gone. Let's drop it. Cc: Linus Torvalds Cc: Greg Kroah-Hartman Cc: Andrew Morton Cc: Hillf Danton Cc: Michal Hocko Cc: Matthew Wilcox Cc: Oleksiy Avramchenko Cc: Steven Rostedt Cc: Minchan Kim Cc: huang ying Signed-off-by: David Hildenbrand --- include/linux/vmalloc.h | 1 - mm/nommu.c | 10 ---- mm/vmalloc.c | 116 +--------------------------------------- 3 files changed, 1 insertion(+), 126 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 390af680e916..9c1b17c7dd95 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -200,7 +200,6 @@ static inline void set_vm_flush_reset_perms(void *addr) /* for /proc/kcore */ extern long vread(char *buf, char *addr, unsigned long count); -extern long vwrite(char *buf, char *addr, unsigned long count); /* * Internals. Dont't use.. diff --git a/mm/nommu.c b/mm/nommu.c index 5c9ab799c0e6..85a3a68dffb6 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -210,16 +210,6 @@ long vread(char *buf, char *addr, unsigned long count) return count; } -long vwrite(char *buf, char *addr, unsigned long count) -{ - /* Don't allow overflow */ - if ((unsigned long) addr + count < count) - count = -(unsigned long) addr; - - memcpy(addr, buf, count); - return count; -} - /* * vmalloc - allocate virtually contiguous memory * diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ccb405b82581..434f61c9c466 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2802,10 +2802,7 @@ static int aligned_vread(char *buf, char *addr, unsigned long count) * kmap() and get small overhead in this access function. */ if (p) { - /* - * we can expect USER0 is not used (see vread/vwrite's - * function description) - */ + /* We can expect USER0 is not used -- see vread() */ void *map = kmap_atomic(p); memcpy(buf, map + offset, length); kunmap_atomic(map); @@ -2820,43 +2817,6 @@ static int aligned_vread(char *buf, char *addr, unsigned long count) return copied; } -static int aligned_vwrite(char *buf, char *addr, unsigned long count) -{ - struct page *p; - int copied = 0; - - while (count) { - unsigned long offset, length; - - offset = offset_in_page(addr); - length = PAGE_SIZE - offset; - if (length > count) - length = count; - p = vmalloc_to_page(addr); - /* - * To do safe access to this _mapped_ area, we need - * lock. But adding lock here means that we need to add - * overhead of vmalloc()/vfree() calles for this _debug_ - * interface, rarely used. Instead of that, we'll use - * kmap() and get small overhead in this access function. - */ - if (p) { - /* - * we can expect USER0 is not used (see vread/vwrite's - * function description) - */ - void *map = kmap_atomic(p); - memcpy(map + offset, buf, length); - kunmap_atomic(map); - } - addr += length; - buf += length; - copied += length; - count -= length; - } - return copied; -} - /** * vread() - read vmalloc area in a safe way. * @buf: buffer for reading data @@ -2936,80 +2896,6 @@ long vread(char *buf, char *addr, unsigned long count) return buflen; } -/** - * vwrite() - write vmalloc area in a safe way. - * @buf: buffer for source data - * @addr: vm address. - * @count: number of bytes to be read. - * - * This function checks that addr is a valid vmalloc'ed area, and - * copy data from a buffer to the given addr. If specified range of - * [addr...addr+count) includes some valid address, data is copied from - * proper area of @buf. If there are memory holes, no copy to hole. - * IOREMAP area is treated as memory hole and no copy is done. - * - * If [addr...addr+count) doesn't includes any intersects with alive - * vm_struct area, returns 0. @buf should be kernel's buffer. - * - * Note: In usual ops, vwrite() is never necessary because the caller - * should know vmalloc() area is valid and can use memcpy(). - * This is for routines which have to access vmalloc area without - * any information, as /dev/kmem. - * - * Return: number of bytes for which addr and buf should be - * increased (same number as @count) or %0 if [addr...addr+count) - * doesn't include any intersection with valid vmalloc area - */ -long vwrite(char *buf, char *addr, unsigned long count) -{ - struct vmap_area *va; - struct vm_struct *vm; - char *vaddr; - unsigned long n, buflen; - int copied = 0; - - /* Don't allow overflow */ - if ((unsigned long) addr + count < count) - count = -(unsigned long) addr; - buflen = count; - - spin_lock(&vmap_area_lock); - list_for_each_entry(va, &vmap_area_list, list) { - if (!count) - break; - - if (!va->vm) - continue; - - vm = va->vm; - vaddr = (char *) vm->addr; - if (addr >= vaddr + get_vm_area_size(vm)) - continue; - while (addr < vaddr) { - if (count == 0) - goto finished; - buf++; - addr++; - count--; - } - n = vaddr + get_vm_area_size(vm) - addr; - if (n > count) - n = count; - if (!(vm->flags & VM_IOREMAP)) { - aligned_vwrite(buf, addr, n); - copied++; - } - buf += n; - addr += n; - count -= n; - } -finished: - spin_unlock(&vmap_area_lock); - if (!copied) - return 0; - return buflen; -} - /** * remap_vmalloc_range_partial - map vmalloc pages to userspace * @vma: vma to cover -- 2.29.2