From patchwork Sun Mar 19 07:09:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13180239 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 C6662C6FD1F for ; Sun, 19 Mar 2023 07:09:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EED48900003; Sun, 19 Mar 2023 03:09:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E9E62900002; Sun, 19 Mar 2023 03:09:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6630900003; Sun, 19 Mar 2023 03:09:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C4712900002 for ; Sun, 19 Mar 2023 03:09:41 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9724D1C63C6 for ; Sun, 19 Mar 2023 07:09:41 +0000 (UTC) X-FDA: 80584772562.09.490EDF8 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by imf23.hostedemail.com (Postfix) with ESMTP id D050514000E for ; Sun, 19 Mar 2023 07:09:39 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bvHAjrvZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.208.41 as permitted sender) smtp.mailfrom=lstoakes@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679209779; 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:references:dkim-signature; bh=h7CWAvSEY2TydX64pSxRJDmGgnmPbocGy/UbjjMMCMo=; b=cam7712DILaEEfu31C6D+yaSDHlf14KeyhBZFilOLdV3/NhP8qdW764BI1mkJPVk3e60xS Q0b4Kuvk+vE0nxkRPIEauX1jYnIjPHF+eou4BlNSjZpTubXnDtryNzgmY/uKGljSdo2QJh YBvrdgm4ANNhMhDKNWwlaYYMnNBEdok= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bvHAjrvZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.208.41 as permitted sender) smtp.mailfrom=lstoakes@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679209779; a=rsa-sha256; cv=none; b=yw6v80iWmngj3Huqwj0RAjF2kwGm5UqLO5zSnOHrF650BQ4SYoaXooL74KLEq6sCX/WOhK D+cB5qR4QQ5i0nVZAzG1c1iCjDlR8EXwFBle07eGln0e2ZBl6XIJlhBHG9TEM8j5JDyj8l t2bJPghkdThTUGSfewZb2kFt+Abbcwc= Received: by mail-ed1-f41.google.com with SMTP id er8so23712364edb.0 for ; Sun, 19 Mar 2023 00:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679209778; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=h7CWAvSEY2TydX64pSxRJDmGgnmPbocGy/UbjjMMCMo=; b=bvHAjrvZeVHCFpT6C21GJEBkh64oyOiWKAEW6g437+AAjXVbxgtn6a2VBqW+bTjTX4 g+mix3ktiYBfYozJwhsdakbwyl0JpWu1+btjJ2G3qaT7Q1fePW2moy5gWQU8dbVouKoa Ru71nCX9aipl2GAW58MVQu4wnUXr4xri4E9s6eJo7DfdAjw4t6zcNGqIGp1X8hr2xkG3 qKvI42XXzOL8C47Gyf99en3XyCojwP4Y4YSos/qOV+Ke1T3WZ8Rv+mYXTbApfK6jIbeB vaOTQCkuD7D0To2mA9ptXXIZI7R7BimpFDrr68WvSR25MtbQAzjEz00gNGBG12+83U4/ s9GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679209778; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=h7CWAvSEY2TydX64pSxRJDmGgnmPbocGy/UbjjMMCMo=; b=1GJR6Uspce7yr8qNL0KPyopYw1LDtWq65pwm4Ql4vxH2WxReoW28e0m+6p/XJJjYUz xur3g952eC+CyOZdl3yi4Y+k5Jvsaby1OGOY1O//3/69HWNfSSsIoR+f02YsM70UJfzp 8Xwi+DIArv7z1zP+4g2PJM33s09vt7xh3UK1pB2E8cxMS3kMDpD49AMSHKRFN1Eyx+Rx 4M3EVO2++BFXAPgzDswIjbXFA0lviplvCPbcEvHnmG/VDCS0Uk1AEL7DneFx2k47oOTo cv1GZL+h2n17GWnYfn4ekD6N97PhSiH0ZvU04epgNXKNZOtQWv99JZoK/QaZUQAqRI25 6AKg== X-Gm-Message-State: AO0yUKXMihsSQBcBnaPtmVjRynZqwRaN0MSeJuvXuagazNhGY+AmjCjn QZUflCiKJVahmdWeEdfLBIGpvtb7f/s= X-Google-Smtp-Source: AK7set9ZN+6uFMowb9J0E6bteotuhvTBs9uIxHBv3SH3j1p97abVzqScTMPB0+fmCXdaFw5LvkZb+Q== X-Received: by 2002:a17:906:884:b0:878:61d8:d7c2 with SMTP id n4-20020a170906088400b0087861d8d7c2mr4831312eje.39.1679209777677; Sun, 19 Mar 2023 00:09:37 -0700 (PDT) Received: from localhost.localdomain ([2a00:23ee:1938:1bcd:c6e1:42ba:ae87:772e]) by smtp.googlemail.com with ESMTPSA id u8-20020a170906b10800b008c9b44b7851sm2943920ejy.182.2023.03.19.00.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 00:09:36 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton Cc: Baoquan He , Uladzislau Rezki , Matthew Wilcox , David Hildenbrand , Liu Shixin , Jiri Olsa , Lorenzo Stoakes Subject: [PATCH v2 0/4] convert read_kcore(), vread() to use iterators Date: Sun, 19 Mar 2023 07:09:29 +0000 Message-Id: X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D050514000E X-Stat-Signature: 815g1ny49hcakjrrskubipdpuira3ioa X-HE-Tag: 1679209779-990429 X-HE-Meta: U2FsdGVkX19P88xatrksoX+8C8Z+9xZALIL55mguYJ1BXsk9rj8mbvcymr5eHIBLdgWtyE2O7/+7AiAAaeXV7qZJYA4/PNa0bKI7fxkA5nGnthCJt4NnxT5GdlUQ4N9Atb14ywDPh90a/veqFp14WJ6EMTJl3iYU5Vy3Gn2GphAhf6xOtkd8DQAWgJd+E6ZU94RjNCvlp8zPl6b1mErgitHduNG5MfzY2HO6G/6kMPD4nabbyW4F1P1p95ccR9bCHt0vuOtRlRzCS102m6sVwBznIIcsyq2xlAG5yLZVxBA0OrK9RhgqBNtpG+JBISXo7GJ+MzNocZYUFlyYnZFKwqAzTV4Y9fpGBE8RUNGqDjKGihz991UGQ9YINEHh27QqBV8cQ9a5BpWeZbMsc/hBTC5ZEEaEpioqkx1XkU4nVbDc4KYz8wHp55ZLItG5H/I2O2eriFn94nV9KUwnQFy+DSlBcRmhh6F4zur2EoJZw/+d8kTVAnrI2m/RSTRG/bR6uDk+kJq0M40l3Z1NqhvUhqmn8hKnryVdDCI9LKBKpmL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CH4= 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: While reviewing Baoquan's recent changes to permit vread() access to vm_map_ram regions of vmalloc allocations, Willy pointed out [1] that it would be nice to refactor vread() as a whole, since its only user is read_kcore() and the existing form of vread() necessitates the use of a bounce buffer. This patch series does exactly that, as well as adjusting how we read the kernel text section to avoid the use of a bounce buffer in this case as well. This patch series necessarily changes the locking used in vmalloc, however tests indicate that this has very little impact on allocation performance (test results are shown in the relevant patch). This has been tested against the test case which motivated Baoquan's changes in the first place [2] which continues to function correctly, as do the vmalloc self tests. [1] https://lore.kernel.org/all/Y8WfDSRkc%2FOHP3oD@casper.infradead.org/ [2] https://lore.kernel.org/all/87ilk6gos2.fsf@oracle.com/T/#u v2: - Fix ordering of vread_iter() parameters - Fix nommu vread() -> vread_iter() v1: https://lore.kernel.org/all/cover.1679183626.git.lstoakes@gmail.com/ Lorenzo Stoakes (4): fs/proc/kcore: Avoid bounce buffer for ktext data mm: vmalloc: use rwsem, mutex for vmap_area_lock and vmap_block->lock fs/proc/kcore: convert read_kcore() to read_kcore_iter() mm: vmalloc: convert vread() to vread_iter() fs/proc/kcore.c | 84 +++++++------------ include/linux/vmalloc.h | 3 +- mm/nommu.c | 10 +-- mm/vmalloc.c | 178 +++++++++++++++++++++------------------- 4 files changed, 130 insertions(+), 145 deletions(-) base-commit: 4018ab1f7cec061b8425737328edefebdc0ab832 --- 2.39.2