From patchwork Sat Mar 4 19:39:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13160013 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 147ECC64EC4 for ; Sat, 4 Mar 2023 19:40:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BD006B0074; Sat, 4 Mar 2023 14:40:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 345816B0075; Sat, 4 Mar 2023 14:40:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AC4E6B0078; Sat, 4 Mar 2023 14:40:06 -0500 (EST) 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 E89316B0074 for ; Sat, 4 Mar 2023 14:40:06 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AC4A312071D for ; Sat, 4 Mar 2023 19:40:06 +0000 (UTC) X-FDA: 80532231612.17.D705D16 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf21.hostedemail.com (Postfix) with ESMTP id 02F931C000B for ; Sat, 4 Mar 2023 19:40:04 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=e3nKr5Xs; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677958805; 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=l8XI5QpQKoTIzhmBo1OGgSbthQInK2OIZNWIDSd9e6o=; b=fQLtK36WZnapGFCfM9fTpuPkQrUFVZwTxIgIXWOIjiMygMhFEcQpJstrJDo/VDSJnjIqS9 AIE7m2WIo5NxteI3SHuv6KmgPOk9xAWcK5OtCI63nXVqVb/hAMc8PsjkAvhzZhrilZtwgr Z6AMTwXmo41ToFLK+mKHFtTNUPdQdr8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=e3nKr5Xs; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677958805; a=rsa-sha256; cv=none; b=PDE4wYMuRS5Kzv2XqwGSyMFFTJ06a7T5lkO5y6UNlIjCN432w1xm65xFJpfs9P8xlxLt1P bH7ekWU/L1ALw+t6CfMSrZaWOfyd16ljvGQmBm5ONM2XlNo3ge6ECAvkN5KhV4AmHH9C8c g3W8OAfLTY5F1q4P3VjA6cH0IcMje9U= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 84E4DB8069B; Sat, 4 Mar 2023 19:40:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2D13C4339C; Sat, 4 Mar 2023 19:40:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677958802; bh=uVtft0lxTja3jBPQPJpnoQbKRCxZP/ST9hjfus9mMms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e3nKr5Xsgp0MN2UPq7FxyhDz5NDDfGt1VW+xC+uwXKXl/fw5Ie91/IKKZwhFgi+yh 9CFrNXy26L4W8ttmk7TxHUh28ikksODKGfRMLce15uwQC3XqMYNKtV7Vj7ORG+oyDP mlPZ/o1VpAT8fNgpNrqGke2yktJx4RWUtx1oHDmE6d0G9zaqXuHyE7Tlxmgl0RG6sB e4OzERuIHep+cFfGL6RNdEEtI2fzu0E7JvEyAElXtJXvcoO/LwD4tObncoLD/62A/t CcLHJgqyFqenktJMegZbT/nUoR0mfKR9Bav6rvN2UVlatGynzpKP55fHXEDqUGwAEf AZ9ZkvF6WyUMQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Kefeng Wang , "Vishal Moola (Oracle)" , "Matthew Wilcox (Oracle)" , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/2] mm/damon/paddr: fix folio_nr_pages() after folio_put() in damon_pa_mark_accessed_or_deactivate() Date: Sat, 4 Mar 2023 19:39:49 +0000 Message-Id: <20230304193949.296391-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230304193949.296391-1-sj@kernel.org> References: <20230304193949.296391-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 02F931C000B X-Rspam-User: X-Stat-Signature: p3i8z5hnq9z6f51ty8hfc9ayfc3pt7ib X-HE-Tag: 1677958804-282561 X-HE-Meta: U2FsdGVkX19evdHAxcOzUkwGiBmWXtTdyCtSwJQQK5TNeQagDz+bKCxO90uaTiRPdW6Mwgyw47EM9vIt+tDRmvZnY33rbq5r5+zw831PD+Xdb6H8Bdh5h5tm4aC0fhhvV+tazNn65lD0vzRk4zSBS7TwDLslFyyJjBwGOe2SQWTJ+T5hDPZBj4cAF94wvxOG361+oPU63giVOCADGmVczbWvX0J7zmKtWx/bVzFzc5t2DKGGaF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6vi6yJCq3ROkDDGEdsdIAV//5CXouoYy4ev0tAV/c3Z2mzICCiNsXfIOtPpkijuX33bRPqMW39IyPoyXJ3t6Q97jpxpqYIDFjApoPqx6N92dlJdaf6r2g3jdHZKnI93vdHan4cQ== 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: damon_pa_mark_accessed_or_deactivate() is accessing a folio via folio_nr_pages() after folio_put() for the folio has invoked. Fix it. Fixes: f70da5ee8fe1 ("mm/damon: convert damon_pa_mark_accessed_or_deactivate() to use folios") Cc: # 6.3.x Signed-off-by: SeongJae Park Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Kefeng Wang --- mm/damon/paddr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 10f159b315ea..0db724aec5cb 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -277,8 +277,8 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( folio_mark_accessed(folio); else folio_deactivate(folio); - folio_put(folio); applied += folio_nr_pages(folio); + folio_put(folio); } return applied * PAGE_SIZE; }