From patchwork Thu Feb 29 23:43:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13577757 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 27C6AC54798 for ; Thu, 29 Feb 2024 23:43:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95FB96B00B1; Thu, 29 Feb 2024 18:43:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E81F6B00B2; Thu, 29 Feb 2024 18:43:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 762E86B00B3; Thu, 29 Feb 2024 18:43:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 613AA6B00B1 for ; Thu, 29 Feb 2024 18:43:33 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 21FBA8041E for ; Thu, 29 Feb 2024 23:43:33 +0000 (UTC) X-FDA: 81846470706.07.8B16CC4 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) by imf25.hostedemail.com (Postfix) with ESMTP id 7E77BA0009 for ; Thu, 29 Feb 2024 23:43:31 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Xx06TLdG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.166.177 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709250211; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8fSQQtv9Pdd1jRnQzOfB2+LAkUYgIfVtnLn4umtyxEI=; b=zoqQb3w2QP0cOeCaDt+WydAeVy+Zx43vw0QahaRLcW+1gtQttRizRXE+9o0xJ1Lk/FZMWi abn+h76WtTmE6yZMNycmdct7TkX/gyrUzq3OKfqcKBdXmu619W7wtrOKGK1EIwJWUUYDkS bBvO4wj1PuLdvKAHbdq8yjL2iK1ILg8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Xx06TLdG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.166.177 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709250211; a=rsa-sha256; cv=none; b=Gw2Tw6pp2MxD1kSj1s72fgKYNmFR+oyqOy3XaleyddHWgW8Uai4XLq6rX1P4ZYbzoddC0h b+JXclJUlgvvS9aV3+fsbrMkpqqmnuQAwFJfyfybT9noIcbmDJUVO1U3HJFrvn+NJo0oYd ungvl3quR1r6t0aIXzIBDrrwcEERaB0= Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-3657c437835so4862385ab.2 for ; Thu, 29 Feb 2024 15:43:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709250210; x=1709855010; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8fSQQtv9Pdd1jRnQzOfB2+LAkUYgIfVtnLn4umtyxEI=; b=Xx06TLdGK0yl4P7DWL/cckhUVwqB7nZbDSx1MfCw3MNaJV5IevzHly0Dlx0/TrU5Be sR52T/ESxjdQroKzgMI5bt/3Wia9jbwip8y26ZwXbDKu/MPTLiztnLCvbv3HYT7Jr1EA LdmFdxr062wRS8yW5V0ajJ3ipmbuQXQ2AkOSbqtLQR/jiL1xR389AF+gzPxK6Bu5rPk9 IpiUKd5LnaUf7oZCsQC6eIdGU4nJCIbqPhORoROJ5AVJJn6v0EFYeX1MHds4nJVPoPEy t4siKHnakGRXCBcchS2tF0YVagWNvmbAFJP0ukPfve7Yx24LqrYX/wiHg6kwHqew7A8Z +yBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709250210; x=1709855010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8fSQQtv9Pdd1jRnQzOfB2+LAkUYgIfVtnLn4umtyxEI=; b=fBUctFhZkPoxg8VB7f14hEvIWb/8H+g2aZRSrod9L9mz53ySoJqj8YpzljPsTejW2g s1X3g6DK9ljZpQzXJVgYx2+naw7NHHoQsm2YZQys/dx/GVibPWJH3Z7SNt1IwfrJkZR3 jWS+apNyGsLG/4gpwTrn9LiOl69UXPF1EuHSbsZJ4/jRiXRTYpZKvy67mWdp1CWhWRom 1s3U+zcO9Dr2SYNKJscg+5vJGhSmrpAgWJ3E3K/d/6cBttfkYuvxHy5yCJ4QzsVqxmxi HK7vD4idY3aaufotKItyC6qRpQfXMcRgh4yhEGn9FfVWxlMw1Hi1cOmMi52ZXSxRVkpa xvtQ== X-Forwarded-Encrypted: i=1; AJvYcCWtATw8oFV4mdZJmvPDNa63sz6CmssWFUXfYdVyTbnCCzmCOHPU0X6xPrxZY0zkD57ipnhc4grL0eRvZ+rnAqY+nk4= X-Gm-Message-State: AOJu0YwMxdiNyFmTiHMpseM01OeH7+iGxWJv8MK1DEX0LZwkKval4jf9 PYqUfx4erumdl09QZDky40Pj8BuyCVZD7SuJCub7CgDxH6eZeaAs X-Google-Smtp-Source: AGHT+IEjOcNXmJRmdRJJTTrs5fHGw0wy4T92DO/fjxQ1ryFJYxgxzO1wRU4PulyZo16hmDAMpzbQcA== X-Received: by 2002:a05:6e02:148e:b0:365:a6a2:24b with SMTP id n14-20020a056e02148e00b00365a6a2024bmr273922ilk.17.1709250210665; Thu, 29 Feb 2024 15:43:30 -0800 (PST) Received: from localhost.localdomain ([2620:10d:c090:400::5:8f17]) by smtp.gmail.com with ESMTPSA id r19-20020aa78453000000b006e4dad633e1sm1850278pfn.177.2024.02.29.15.43.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 29 Feb 2024 15:43:30 -0800 (PST) From: Alexei Starovoitov To: bpf@vger.kernel.org Cc: daniel@iogearbox.net, andrii@kernel.org, torvalds@linux-foundation.org, brho@google.com, hannes@cmpxchg.org, lstoakes@gmail.com, akpm@linux-foundation.org, urezki@gmail.com, hch@infradead.org, boris.ostrovsky@oracle.com, sstabellini@kernel.org, jgross@suse.com, linux-mm@kvack.org, xen-devel@lists.xenproject.org, kernel-team@fb.com Subject: [PATCH v3 bpf-next 2/3] mm, xen: Separate xen use cases from ioremap. Date: Thu, 29 Feb 2024 15:43:15 -0800 Message-Id: <20240229234316.44409-3-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20240229234316.44409-1-alexei.starovoitov@gmail.com> References: <20240229234316.44409-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7E77BA0009 X-Stat-Signature: s5nxq8nh11qofgdphoz3sxapr4dtymx1 X-Rspam-User: X-HE-Tag: 1709250211-769498 X-HE-Meta: U2FsdGVkX19EonG7wifAT61ACC5tuCoxpr+1yWZhvK6g7y7fnc2ymt/M6gLCtzWUwqmH+xtiHgmGUs4a/SF32sVD7wmibBxYjV1BbhSBjuwg85GBuJSMAXQfd9tI1bHIM8sTKhhGgfJ4JyVOC45rNA/0own1LRzBvN+91iwHBfOKliRgLpA3AUiYvhGYulbMcxxSpj2E+VIS1kJdGlBqPb4R9InpJibmiAdTGF0VWmJVMcUXLHRvUl8gCktvCBmdlhrKmKn5mp/4qqojx1bFpZab5HOSgoWmqAYhBYF081GEUtSPRQeo7hwlUTGTS0L82xsa0bi0Wnd8SMFErGehdm2AEFaZ8IU3l9u1WmY7gDnxoYBK9WxizMh6arhU0+uO1YGW+i7SAHJIZ71MpCXS6i68bScXG0hWbZTyM22kSJNkuD2WFtrFKKN5yeI6HE9yRgE4Hiw/MulQq9Poa2JAmVqsfh4GwTB5QvMVYRIKHn7+L2drsPObGLZ99Rb/oSkzzte9p8cnpte8U0YbU0ea1cDqtx8SQmwjjnazS1odzl+3IbFKegGWjKRduGGc6h6GlLILxt4Ib58rGIsfbOs7z49E5XHqBeYdCn4qjuPnrihHt2jDz0dhlD4mvjlGmSuPAExhnlFLW6gL+j1nQaHJTf2FR2g++PTRh4rTcUDYBHfTJpgq0TVSWPyne6qels1sAoJbCbu/YWiCR1dPN0d10CGbw/RsbCfEA1FwaN8srVX7NuHMC8NL8Lc06cD4iAnEydaKva98GwjVmYElt+KTOUnOCdpQ1/CMCgt5wrlJ4uKlxA0pVox+2CWwRhvXRa5JRosMKg5uzWBO7bK3BQs9LoPnZkH0RwvWTBnmZywPSAPnLPUe4tGzpdWdYure1584KbtCj2t4lAWyg6LyNyiw3USk/WOnsfrUQSJADBWnXQPFSLDvCe31EIVMIYlh+gjwLcVS26AgprJZZdACEcG zi61/rfb 2vhMSdQDJbciRKT5SGOlANCklJv0/GUyMwqD9xDvgPEaNr5xYg8cD3ADgJJh058wMZuNrBgfhJI7kXK2lRZsP6vPebz6AzSVNzEbwpsih73KOctawTHdoA6fCBtK0k5z9CoI50PlSMdLYZ2YkYZ2XJF0f/A== 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: From: Alexei Starovoitov xen grant table and xenbus ring are not ioremap the way arch specific code is using it, so let's add VM_XEN flag to separate these use cases from VM_IOREMAP users. xen will not and should not be calling ioremap_page_range() on that range. /proc/vmallocinfo will print such regions as "xen" instead of "ioremap". Signed-off-by: Alexei Starovoitov --- arch/x86/xen/grant-table.c | 2 +- drivers/xen/xenbus/xenbus_client.c | 2 +- include/linux/vmalloc.h | 1 + mm/vmalloc.c | 7 +++++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/xen/grant-table.c b/arch/x86/xen/grant-table.c index 1e681bf62561..b816db0349c4 100644 --- a/arch/x86/xen/grant-table.c +++ b/arch/x86/xen/grant-table.c @@ -104,7 +104,7 @@ static int arch_gnttab_valloc(struct gnttab_vm_area *area, unsigned nr_frames) area->ptes = kmalloc_array(nr_frames, sizeof(*area->ptes), GFP_KERNEL); if (area->ptes == NULL) return -ENOMEM; - area->area = get_vm_area(PAGE_SIZE * nr_frames, VM_IOREMAP); + area->area = get_vm_area(PAGE_SIZE * nr_frames, VM_XEN); if (!area->area) goto out_free_ptes; if (apply_to_page_range(&init_mm, (unsigned long)area->area->addr, diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index 32835b4b9bc5..b9c81a2d578b 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -758,7 +758,7 @@ static int xenbus_map_ring_pv(struct xenbus_device *dev, bool leaked = false; int err = -ENOMEM; - area = get_vm_area(XEN_PAGE_SIZE * nr_grefs, VM_IOREMAP); + area = get_vm_area(XEN_PAGE_SIZE * nr_grefs, VM_XEN); if (!area) return -ENOMEM; if (apply_to_page_range(&init_mm, (unsigned long)area->addr, diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index c720be70c8dd..71075ece0ed2 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -28,6 +28,7 @@ struct iov_iter; /* in uio.h */ #define VM_FLUSH_RESET_PERMS 0x00000100 /* reset direct map and flush TLB on unmap, can't be freed in atomic context */ #define VM_MAP_PUT_PAGES 0x00000200 /* put pages and free array in vfree */ #define VM_ALLOW_HUGE_VMAP 0x00000400 /* Allow for huge pages on archs with HAVE_ARCH_HUGE_VMALLOC */ +#define VM_XEN 0x00000800 /* xen grant table and xenbus use cases */ #if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \ !defined(CONFIG_KASAN_VMALLOC) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index f42f98a127d5..d53ece3f38ee 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3822,9 +3822,9 @@ long vread_iter(struct iov_iter *iter, const char *addr, size_t count) if (flags & VMAP_RAM) copied = vmap_ram_vread_iter(iter, addr, n, flags); - else if (!(vm && (vm->flags & VM_IOREMAP))) + else if (!(vm && (vm->flags & (VM_IOREMAP | VM_XEN)))) copied = aligned_vread_iter(iter, addr, n); - else /* IOREMAP area is treated as memory hole */ + else /* IOREMAP | XEN area is treated as memory hole */ copied = zero_iter(iter, n); addr += copied; @@ -4415,6 +4415,9 @@ static int s_show(struct seq_file *m, void *p) if (v->flags & VM_IOREMAP) seq_puts(m, " ioremap"); + if (v->flags & VM_XEN) + seq_puts(m, " xen"); + if (v->flags & VM_ALLOC) seq_puts(m, " vmalloc");