From mboxrd@z Thu Jan 1 00:00:00 1970 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 1D721C4332F for ; Mon, 17 Oct 2022 16:18:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 997516B0074; Mon, 17 Oct 2022 12:18:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 947106B0078; Mon, 17 Oct 2022 12:18:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8356A6B007B; Mon, 17 Oct 2022 12:18:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7571F6B0074 for ; Mon, 17 Oct 2022 12:18:07 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3459680DDF for ; Mon, 17 Oct 2022 16:18:07 +0000 (UTC) X-FDA: 80030948214.19.6C97C8F Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf05.hostedemail.com (Postfix) with ESMTP id 95F7910003A for ; Mon, 17 Oct 2022 16:18:06 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id d24so11227623pls.4 for ; Mon, 17 Oct 2022 09:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nPOgLKtqJqc/KkUndkqLjqrqFd6Qi0PDVLbeuKh7FTw=; b=q4cfhBfNy4i8qzlQX6+OteLtFU9IPky21iCQeSAduA33cWBF/akGv01p4X2WqaAypq Qz9U3QYo9P17o/x1Wnj5iIuERGQJvlMW5/jyUthYy+SNEesjFzSnYy6uw5cgR1qPoKTc Ekn9Y0Oaatou+qg4G0Eaxf7nxzxpZmDH796Qamf9kkTd2ptegwWHOo+bpOHjBYZx5NOp 9Ci57iNswficoBuLd6IX2pDr7uStAaWB+K6W5ISfXQ+xVI0D0tzRJBPUBgs5igMaa7Am ZXRfdFClTAuFsgKi8GPPg5O4Ocon3+Bh8simIG5nuTt3/bDWk5eKXuim1Y8+yy0d6/Ue QKYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=nPOgLKtqJqc/KkUndkqLjqrqFd6Qi0PDVLbeuKh7FTw=; b=LQc3QGo4jWLg5aU1C6HGCJ8mrxZriSnLDrnE5pvQQiJvakNq6heLktWUeyDtIUVrZM n/ckmIBiAAWYZHdyvhOJHSscUskb/74kSbFSWrnwSm3ktsUqvhNOskRC9h6IgrEBbk/b Lf2z98JMK1h8CypD5pKTDdpwfwovx2hNcs/fzcFvyGmeE0a7xPy5IyFKsi8r+jUIJbvw qixmbOnmkzwDoI2Y5zJvWZs4irg3sAh0yeWhWCvVWf30IUscDWVL2fQ6WX9z0BE9a+mY d6iq41i4cgXLRzVHHlLn4mJfDomfF0LeHJyhKo3P6vrD5LTRQ8Ods82flCffasn6Iat8 0ROA== X-Gm-Message-State: ACrzQf2kAtDwLTBvr+Vtqpk3zL1ruMDnpcesAwn3T7ZQ06kIiJGc5THx NIL+lKc5QizE6zyGgTZ6gHM= X-Google-Smtp-Source: AMsMyM5TTPDWNe4izGZlGnC0+XsuJnNJBl+hb+FP55XZjAsmo33n/GD+2CnVAKmNDEFYy4AdR882Dw== X-Received: by 2002:a17:90a:890b:b0:20d:981a:a5b5 with SMTP id u11-20020a17090a890b00b0020d981aa5b5mr30088023pjn.186.1666023485280; Mon, 17 Oct 2022 09:18:05 -0700 (PDT) Received: from vmfolio.. (c-76-102-73-225.hsd1.ca.comcast.net. [76.102.73.225]) by smtp.googlemail.com with ESMTPSA id z22-20020a62d116000000b0055f209690c0sm7272326pfg.50.2022.10.17.09.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 09:18:04 -0700 (PDT) From: "Vishal Moola (Oracle)" To: akpm@linux-foundation.org Cc: willy@infradead.org, hughd@google.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH v3 0/2] Rework find_get_entries() and find_lock_entries() Date: Mon, 17 Oct 2022 09:17:58 -0700 Message-Id: <20221017161800.2003-1-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=q4cfhBfN; spf=pass (imf05.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666023486; a=rsa-sha256; cv=none; b=ZbvHtI+MkZ/bH9RXJWcXHT6RyRTGw7J6FN6LzK6CfrTBy+ooH8swIH3hhudcsJFPhCdT1w Wny8K3Ty+mGv8hjroOIMw4etQPys3W8S2UJkNELGd2hgIjjS0dX/v/npKEk6SVr1AB2JlD 7om3A7nzszjFAnZSPy548s2NKq05rAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666023486; 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=nPOgLKtqJqc/KkUndkqLjqrqFd6Qi0PDVLbeuKh7FTw=; b=s5qb9431On5P4D+Ag2oe6SA08pxnHhiTcokKuJ0azkti7hXNL9PBFZQM2t3/FTNYcL+661 pUGHic10MHcFJ8UfuD2EBTFD9ynZJ4Nbq2kZOKyrMm7V1FUi4XgFdTo8uNO77Ihvvp/osn Gx8qgQ8HJ5m5ucqy9LErLbq3tqgxGug= X-Stat-Signature: 4f955szfb63dhepfd9iwhhhqrdyd5bom X-Rspamd-Queue-Id: 95F7910003A Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=q4cfhBfN; spf=pass (imf05.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1666023486-47078 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: Originally the callers of find_get_entries() and find_lock_entries() were keeping track of the start index themselves as they traverse the search range. This resulted in hacky code such as in shmem_undo_range(): index = folio->index + folio_nr_pages(folio) - 1; where the - 1 is only present to stay in the right spot after incrementing index later. This sort of calculation was also being done on every folio despite not even using index later within that function. These patches change find_get_entries() and find_lock_entries() to calculate the new index instead of leaving it to the callers so we can avoid all these complications. --- v3: Fixed a typo in commit messages Shifted calculations to after the rcu_read_unlock() v2: Fixed an issue when handling shadow entries Dropped patches removing the indices array; it is required for value entries Vishal Moola (Oracle) (2): filemap: find_lock_entries() now updates start offset filemap: find_get_entries() now updates start offset mm/filemap.c | 28 +++++++++++++++++++++++----- mm/internal.h | 4 ++-- mm/shmem.c | 19 ++++++------------- mm/truncate.c | 30 ++++++++++-------------------- 4 files changed, 41 insertions(+), 40 deletions(-) -- 2.36.1