From patchwork Tue Feb 6 22:04:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13547838 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 6DF43C48297 for ; Tue, 6 Feb 2024 22:05:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F09EF6B0087; Tue, 6 Feb 2024 17:05:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EB8E56B0088; Tue, 6 Feb 2024 17:05:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D59746B0089; Tue, 6 Feb 2024 17:05:00 -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 BDCD56B0087 for ; Tue, 6 Feb 2024 17:05:00 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7CD871C162D for ; Tue, 6 Feb 2024 22:05:00 +0000 (UTC) X-FDA: 81762759960.21.B226E4E Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf28.hostedemail.com (Postfix) with ESMTP id 90D11C0007 for ; Tue, 6 Feb 2024 22:04:58 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SJ9DwrPc; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707257098; a=rsa-sha256; cv=none; b=59Zw2F09kBUUOHtrp0ptsiMcJV8g9Qch8LL/5SQpbAtecJ+Xeuwgt9hwGr+ZNvsmMwdRLt HGJy0Kbmr++mrnf+y9E8Dc1GbxM+Xvhe4W7MJj5wKZbP2UIRArywXn5U15NHKjZBx2t6OV LtDFiunfJNPiriygepXbcpfOLHAuPSU= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SJ9DwrPc; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.210.175 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=1707257098; 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=3Tj/XQbWXLMz6O6W1qhMmj7yBJ5q6YLDIAk/QCdta60=; b=e9vF8LXbiiLINITHV2uBcWESvcs2oqq07tmTJzuDPs3ygMQjjwvoZsdIWBDEceYYwq+heo pt7SXWNI9fCDC69zImlir1eoKYlGQmj+IkXcj5qRaZ4sigroyUdU1bfjqPJg2PWmjQNXAq 00qNrMHTT6lzK2jTPqscV1t3vJyH0VE= Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6de3141f041so24815b3a.0 for ; Tue, 06 Feb 2024 14:04:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707257097; x=1707861897; 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=3Tj/XQbWXLMz6O6W1qhMmj7yBJ5q6YLDIAk/QCdta60=; b=SJ9DwrPcQylHcjUud8M7Z946seypusXtfaFoiq672Fdrik0E/HtJs7m7jEOf2CKASz H8XSP6LOV2nPujZVaLVS0T/eEwsbVeg61Fnqw6sqPZHY0V/0SQcAUGDw6MDRYDvkAgZL 2mOKFJUoa9yKKQsXX2PPBeHa4r8U2IsuIemaAgNHgDxUa2N0UeDYCp3sOHHEXc+NkWxK sloyrAuai31aRYt+Ut3a/daqfowS+sPdGkJvPaTW3cqahLk76dbXteIbLdloSXsNd5O2 k3wNrfz2iz+nf6afoFBuR4PDM7B352hBqptGcxXuDR+udT6LTXIJW21P0Ym88QDSj6HO N8xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707257097; x=1707861897; 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=3Tj/XQbWXLMz6O6W1qhMmj7yBJ5q6YLDIAk/QCdta60=; b=R7q+Vr8GCkiQiXQKxJbNZVPv3IEquea1d7l6l6XBfiFUgPuE2PSd1GXKGWfiy47G+/ q4RbpvjuMwupy1XQJxWyQoTo/209fU9O+DQzSBNXOtwDHx4LLDdCc4iAG0QKYH4gdCEj XHcTEoGsoIeQhG+3pc3vr+KUaPT9Z4xwTqhn6My9HTOL1kQgU4vomX6sfLb0C9r56oLg IgZsIA6EY8dOaReCJkY8GjjYVUdzTNC/feRsLJp+V2v3X9umAcZIjF0SaN6xE+vxDLck y8zEJiO4l6X30hdnV2yxCDEKG0VrbvbldsvQSDZmDm/74zrHhMu+qNwBeTBDIrR3LVOX 9Q+A== X-Forwarded-Encrypted: i=1; AJvYcCUuBQAWSwdGhtvb3Kb3DG+kO831GZFq6VP7j0v+pwugFfmost2SAEK1KSbdfg3P1oghLD4AlTOz4rIxSLsGNXCMdVs= X-Gm-Message-State: AOJu0YwgYH/LUH8yWezvU0JVf5VBVVAgFsHnfYWBioD1XaL8A5YFCZsE ECn03TnyGg1KOi0qb96AhoBSIIAOv/Kbgh2JxEeD73ZM0KjaHE7Z X-Google-Smtp-Source: AGHT+IEjcAf6uXoS2ZepvZd4WPEhsb74cH/NcraOd61wF2bJGbGsztqlhDT3saZuKsz+GWEev5IaMA== X-Received: by 2002:a05:6a20:3598:b0:19c:2a8d:8b75 with SMTP id j24-20020a056a20359800b0019c2a8d8b75mr2472114pze.28.1707257097406; Tue, 06 Feb 2024 14:04:57 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUog5B9mBd/4ypN4iPfsLncV0Q6zXF9MI3t+m9OSEmXJlkyaYwbJU3Z5CWn6TyAb2DiJtsdoKuHJLryjn1E+YF6B9ICtSLE8PV+NwaK7s/bobASa1TzhWkioQw/pNKVdOB/uuhkbiOyjjZJRLYOlpKWVmq5s3/lmII40TDt44WDD0EUbz7vv76WbdbJJBqhRa1G7/kQyL5mMT0bXWt/GXEdG4CTcUpNAwn3jDPEp8+fy2NVxuh9M65ywbwVm9XrCApUkiY64O7kR5q1Bkwzb8au/2GMwMcXdy3L Received: from localhost.localdomain ([2620:10d:c090:400::4:27bf]) by smtp.gmail.com with ESMTPSA id c1-20020aa78c01000000b006e02e816f13sm2491180pfd.111.2024.02.06.14.04.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 06 Feb 2024 14:04:57 -0800 (PST) From: Alexei Starovoitov To: bpf@vger.kernel.org Cc: daniel@iogearbox.net, andrii@kernel.org, martin.lau@kernel.org, memxor@gmail.com, eddyz87@gmail.com, tj@kernel.org, brho@google.com, hannes@cmpxchg.org, linux-mm@kvack.org, kernel-team@fb.com Subject: [PATCH bpf-next 03/16] mm: Expose vmap_pages_range() to the rest of the kernel. Date: Tue, 6 Feb 2024 14:04:28 -0800 Message-Id: <20240206220441.38311-4-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20240206220441.38311-1-alexei.starovoitov@gmail.com> References: <20240206220441.38311-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 90D11C0007 X-Stat-Signature: qwbing99164w786adhcipgmgxg65346e X-HE-Tag: 1707257098-203330 X-HE-Meta: U2FsdGVkX19eQZ1HpVHFhIpuDMgjmO2ShY1ZQoN6txUUJKkypIFuPWNUJ3FFRCpn/Hv47ESEwA168zK8eH3fAyuvfINrLXARhsx87bS38wqserw/U/KEjy5hc318v5Qi9MHA7yVbc7RtpT+ecN/Mqfh7/byzYJdlZbzaMQcsMmq1gjYq8/YJ2PQThIfwg1WR2LlN4b8A6Ly/hNVmuhdf37sv4oU0WX2mjJiNwRYqYZaXRJVsEJSuMgM9VH0yB2+1Wo4jzwkZ3JmIO7luGEnTlr8HbC9Bu/vfvX6y9QhGVEMCpOaXul2y2faQtsIqoz/cWNV9R7zUiL+CT0ST1kA6jC83TPi8wqkA6Uuq1OJE5OijStI5f1bkjewrU6a9lo6vKQQtL1QmAjTuIIbCrfgaYR7Zwc7KBJcUca0dvKxp3hXRfSXbLknjRvP2AwXVBEXJSa/36Zf/dAQu2I6Hitojsy54NyMbjDLIcAo3hd+6r2084Wm1yjSkUhVzHBvl+KKwEZgSzf6G7XozTBzogFidQCA1RhRDsmY66IzdX9hcHG4ajsE19xGq2g9H3EXOn6gAGauM7DmVzZD5GiRro9jUTa0Xpk6a4QAJfMpKLfbzJD446d0AiKVzvFZN0A8gkX9ivhVoSEuuSnVEOYJytNDiLJicHL/nUw/SR3NDlXKVGWXAN1cnj4jlFkHB02PERmDR//0pAros5+JwADdKiuAoLP+AnHbsQ5m4BOs1WUOz5vDWj+E6PsWlhaRE2OJL05Sq5k3UBKPGuhTfALFivZf9PJFQ+bf0NP5i1ChRBiievAxP6ky0N18ny4NNNY9ztASu0BVzOZrDxcwR58H+PjxD3fqnaTud38djChinFNhDD+9GAlRJJKeSFs2gdZB0Hms87iFLX3Pd4fw9Fv+0ZW7JNPpEAclxDdhpKctHK4Kohzqnexk5ZjsABjruUfCw5ccqi2pDz432nnMogm4Sqqv 05Jlcysb 54EVtpRtOyqzNb4CVfIhA+MposMwoP1TWpS/L1EoSYiYblgIdd84DFNqEPdEzKuQqOso/G/Nw42B6sao17LspqDqGk3PStxoZH6PU39SlZc0EsSkrgmABgrxFbT7s4aA217OnEzlh3fjwnqJdoDniTaGWLIRdVVhDddMWLP15Wudq76LyiHKkIYV+hXysm5wlPhOICCXOzg6QLgTKAruA7B5HJalvAEg7mYQ7cI092IFtRvc/br3amBTTWALq5Zoc+fRhS9QBhMDdgLyStzh2cE1W/ToktXO5zyHYdufdMDRgJRPi/FtGvm+pBPtOk+qbhCw7P41udNstVlw5ierdeA/UZfXzu7Qg6br587pYZi6s7mR8QhKoCXilk4Z9oCWW4anHxAJK6wyUeri+sYp+6X7wq/HhgmPRSMN/m3EHFt0fUYUKMlTvyCIzihbzhj2xx5RjOv1muCToeWaf8M+CQbDixWA1+sQbJwjt+C1wZLMgSfT1jkNu/n1MHHhsUDsdXF1hhPV9So0tuLCI7qw5hxG2F9zDTNyEa8SPkDRt+5qByTC96J8qolcpYlrVJgSjS0jKySbZQgQvs4k92dzwraTK/909TQEaTux7 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000090, 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 The next commit will introduce bpf_arena which is a sparsely populated shared memory region between bpf program and user space process. It will function similar to vmalloc()/vm_map_ram(): - get_vm_area() - alloc_pages() - vmap_pages_range() Signed-off-by: Alexei Starovoitov --- include/linux/vmalloc.h | 2 ++ mm/vmalloc.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index c720be70c8dd..bafb87c69e3d 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -233,6 +233,8 @@ static inline bool is_vm_area_hugepages(const void *addr) #ifdef CONFIG_MMU void vunmap_range(unsigned long addr, unsigned long end); +int vmap_pages_range(unsigned long addr, unsigned long end, + pgprot_t prot, struct page **pages, unsigned int page_shift); static inline void set_vm_flush_reset_perms(void *addr) { struct vm_struct *vm = find_vm_area(addr); diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d12a17fc0c17..eae93d575d1b 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -625,8 +625,8 @@ int vmap_pages_range_noflush(unsigned long addr, unsigned long end, * RETURNS: * 0 on success, -errno on failure. */ -static int vmap_pages_range(unsigned long addr, unsigned long end, - pgprot_t prot, struct page **pages, unsigned int page_shift) +int vmap_pages_range(unsigned long addr, unsigned long end, + pgprot_t prot, struct page **pages, unsigned int page_shift) { int err;