From patchwork Fri Jun 23 06:26:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13290031 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 7AB9FC0015E for ; Fri, 23 Jun 2023 06:26:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE2B88D0002; Fri, 23 Jun 2023 02:26:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C91AD8D0001; Fri, 23 Jun 2023 02:26:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B59308D0002; Fri, 23 Jun 2023 02:26:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A24398D0001 for ; Fri, 23 Jun 2023 02:26:12 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6AB2B40D34 for ; Fri, 23 Jun 2023 06:26:12 +0000 (UTC) X-FDA: 80933027784.12.A856451 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by imf03.hostedemail.com (Postfix) with ESMTP id 829FD2000B for ; Fri, 23 Jun 2023 06:26:09 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=uYDW4ZN3; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf03.hostedemail.com: domain of dan.carpenter@linaro.org designates 209.85.128.41 as permitted sender) smtp.mailfrom=dan.carpenter@linaro.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687501569; 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-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=ZdFRPwIpzTk0k/qrVNkicgaQ/q36X641ga6hn2FeuTs=; b=aqSQf7+bJwV9RGaEwggVM6P9eE+72uqg/m9Uqusd2VU+RNRPtTQjkEmZ3pnyBCdTJ8tn8I Q9rne7Z+jfIAxeYTBtLeqp4nAik/aL2RO2Mw1gY89mTwigBKqsR+Qiqappp/zqoA3n2NGm vsBpd9YNd6SlAlJ1nzG5vs7d40BMlnI= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=uYDW4ZN3; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf03.hostedemail.com: domain of dan.carpenter@linaro.org designates 209.85.128.41 as permitted sender) smtp.mailfrom=dan.carpenter@linaro.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687501569; a=rsa-sha256; cv=none; b=UbpLF1h3oTdReD0XihMpTQN4V6giIjvjL3gs701KKcrT1nWcwpnsJrIC2tslJ/0BUe9q6i 03Y03XMu+T7dsjmdXTguiOUjGlyW9RvJsmDb4Mj6oM0IQwiIh8qFO8RNE+h91USH+KGkgw K/60th4qmfcJKNzVoD9rz58NwKBqz4s= Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-3f9bff0a543so3909705e9.3 for ; Thu, 22 Jun 2023 23:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687501568; x=1690093568; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=ZdFRPwIpzTk0k/qrVNkicgaQ/q36X641ga6hn2FeuTs=; b=uYDW4ZN3IzogoQcVuJNGSGWVMwaz2c9DfyoC7qyXxo9e5N/0Eqzt5ihKXnfrU913Ix 9mcUjG8y2+gquIhpgayGwd7hIzielvswQH3MTh6x7YG4jqi+eS6T8Obp02r1iy7JGO/H Wr/V300WLVzwlaef5ybb9aqtEJR7Bj13FRWlyS+qLsSlGWkzhts9mycKR94eFXsNjRO0 CezDBFGzrYEYU/VKU2LVBnw77gkbM7G9d294EOsRced7txoG55ihkASp996osIV2euGI bDRA5SK4Bg05UZE0Ul8rLWrUgjrtfc1NgaF5l1dQML/XaKfWCs/wnGbsfD4OoIZPpIFJ Ypfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687501568; x=1690093568; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZdFRPwIpzTk0k/qrVNkicgaQ/q36X641ga6hn2FeuTs=; b=UT9T73faKHnsPGlP8G688FdRSv99izL29vEzSWfqa19oeJ0Daj+3dSN+hxH3HKUdbb 6b0VUSu6zgRtxGUcKpy5QtMe/Gzyiz8YttYl+4Zpr94nx0s9eqnvgLRHQnJUyzjGojB/ oU/YE74Kq+R5UBN0PEGnCVYurP2jeaSEjdEGnK/10Ak4c9EViv07tx96jvVTChrEXg3l toY35RoYr/GLLlUVuUfddyqe63prxTVOXTvpFXmSJmWu/3E1i14qMBZaDrissS0ErP87 Y9jLhEHCoZ0nxhE0sibgriW7hI932923CHgzEpIKgYHG6ygpJ4HH3bYgc/yKTWgv+Wzn TDdQ== X-Gm-Message-State: AC+VfDxIyxW7p+bGcwrdgV6HzPykLzcQp3cF/UIVI34W/u9HACcoRtN5 0avlreh+fP8aYqmdvrkMFLGmtw== X-Google-Smtp-Source: ACHHUZ7VEewFTpl/xMnWD50YBKgpY7nOkzln5AIOV5ir9m0t1JHDVJ8FYmnApnxoE5lyC8wVxU0xhw== X-Received: by 2002:a7b:cd89:0:b0:3fa:77f2:e255 with SMTP id y9-20020a7bcd89000000b003fa77f2e255mr2326234wmj.5.1687501567879; Thu, 22 Jun 2023 23:26:07 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id i5-20020a05600c290500b003fa786b5195sm1330218wmd.42.2023.06.22.23.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 23:26:05 -0700 (PDT) Date: Fri, 23 Jun 2023 09:26:02 +0300 From: Dan Carpenter To: Mike Kravetz Cc: Muchun Song , Andrew Morton , Sidhartha Kumar , linux-mm@kvack.org, kernel-janitors@vger.kernel.org Subject: [PATCH] mm/hugetlb: fix hugetlbfs_pagecache_present() Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 829FD2000B X-Stat-Signature: ky5jmxofthqdzw6w3gmjwq4ztdhgzy9x X-HE-Tag: 1687501569-517159 X-HE-Meta: U2FsdGVkX1+50V/KrroajN7mLXiEjDj0hLGz7JniQ1JoKmDWfphHETArF5G+a7ioMjBhgNx/BlIW+j2gocb2qVXUURhVhetinhF7BiGIB2pDpYe68kfuec2K9B4E7OLTcP0WpS8PMMrHQM6ofdqbq3GsQU6SFzFkcXqhmGT3wz80CvAJ+gcpIlNaqBPUp1v6B90cCdq0wBCscF0XuZu56ifayHxdQkxeGxZwNvuiKolwmodIoUvkc2ANCe4exl4J9moscmi+1uhPl/L5TILjS6gf3crgRSOLz53inDd5jSVwAlZm591t74ZTe0XsHXiJ6gTFLpsT79qgZPeMlwX1h/5UqkvAI9HShW6Iio0GhuXHW7rVwUcJrNF/1uYxcL17+M9ycWQhfP3ATdAg3yCaIFwAZq3Yu8/Lfmp6JkOG3LMssQ6jCRK0k1T46DZWYEphArLgf2CaxcefyRWXX3XTYFQ9s+VeJ3bElP6XyrIsdIDke4N1HKdw5vYo4n9DNdzzqzY7+aSFyGY7aYQI3KCI7pG95mG//lhxSiyRPl+wAX2YQyxctlodJwaYlALoK62LuGx87U7sJTif7zp7ebCzzdm/5p2LkLRlDHqPAhAk0St2jtCzYd4vKR/r5XJLyCpTY04ctFDd2t7DFVIDNp9+HrC+Gq3aVCH7j/xVpEf2e6/zVLPGsJ7MiXxpokBZ0WS8BQ1Lohfl9Emrvtw9JM0fmuCKGEN4tabhAAhaRsZGuzbYmVDcisbXx+YyUdTaPYrBLJS4PhNZQ4WGsfK6aDPGhqJr/Th/Jw0iUBMhJQIxlX8rAAt53CRM7LucKUrKGvFxWL4cBNKe5Bjb4b3BTdlA/mu/D4JoTgVlkne8HIa2vKI6MTFM97Gs3DERgCRrloC3DUV6Qon5CFCjzLbP+RMPE8xW4Xo+/WngeYjlPMGoMBodK/oPaEtHx1kBgeKA7xNzs4t1v1qWEplakHmHvH6 yBvyUG0T tUWuAVRUqS4FHotdUKWxjMSkW4V2RxjECuCDYll0661neHfAyvtGT8KA38eOkVg32h8hpAMmlFt3lyvXgR9fPdvqUgpHdZWLPSYMugukdhiad+3xo5GDWU9fp3x7tpa/vQBgX3OA2kAvRS7JoPK+WpGVUTQ77YJajvsLxmqB2iWfEMzicuMfgSW8L+7NQjgFwpxkwylaiLuZYoQX8JawWOnImJzdwXAwfA6F7x2IM22fL3VzfStlcNKnhT65b/WgFtsK2v+h6FVacjBSnyI2rlDq7KDzsql0SEiB+asXGf5Hc0b3EoRu72MGETtAlJzLeC5bBn9KkfQZVHD5D1WIvwFWhF+ywdNuronWH02yn0EKQudgMaq9qzpKdD+BzMSSQOoABzP40wh5kA1dDTX7LIKS/AlDkl7e6odwA7GKr3ppPW+LUlxS9w9pNRDjMPJvTh9j0 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: The filemap_get_folio() function doesn't returns NULL, it returns error pointers. So the "return folio != NULL;" statement means hugetlbfs_pagecache_present() always returns true. Fixes: 267d6792f43b ("hugetlb: revert use of page_cache_next_miss()") Signed-off-by: Dan Carpenter Reviewed-by: Sidhartha Kumar Reviewed-by: David Hildenbrand --- mm/hugetlb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index cb9077b96b43..bce28cca73a1 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5731,9 +5731,10 @@ static bool hugetlbfs_pagecache_present(struct hstate *h, struct folio *folio; folio = filemap_get_folio(mapping, idx); - if (!IS_ERR(folio)) - folio_put(folio); - return folio != NULL; + if (IS_ERR(folio)) + return false; + folio_put(folio); + return true; } int hugetlb_add_to_page_cache(struct folio *folio, struct address_space *mapping,