From patchwork Sat Mar 4 19:39:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13160011 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 65D57C6FD19 for ; Sat, 4 Mar 2023 19:40:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 606666B0073; Sat, 4 Mar 2023 14:40:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 58E9E6B0074; Sat, 4 Mar 2023 14:40:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42EAB6B0075; Sat, 4 Mar 2023 14:40:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 34B646B0073 for ; Sat, 4 Mar 2023 14:40:06 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EB6721205E4 for ; Sat, 4 Mar 2023 19:40:05 +0000 (UTC) X-FDA: 80532231570.20.BC2F9EF Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf04.hostedemail.com (Postfix) with ESMTP id 3E3C74000B for ; Sat, 4 Mar 2023 19:40:04 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kziuyNZu; spf=pass (imf04.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=1677958804; 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=klm7pnrwFn/X2JkkrxJx+ttziTax9gOlsMmofh2ZMFw=; b=8ow6RAcF06hapQ8NvY5ESEhzew/5VfFOWOBbzs+rgbjEUNipGZeXbNYZWKeBB9ORKInv7e JG2UHAi0c6RxKtWmWDKki+7EkgJJY3ufDYalmrpqxLhBkumUMvAbsEK8hgy7mcvd3Miq9c p+nKr09iD1QqCTmf+1R3HviMdubp7Xg= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kziuyNZu; spf=pass (imf04.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=1677958804; a=rsa-sha256; cv=none; b=j1sU9d8PKBZD4VvaFHerwrEU7hq14ULlW78T6b4ITPClIOEjVYdKdwzF0Cxtbwbd6Q4paA DZ1EYwn0s3Ljjx1xsqPVRMoMoa708owTeVqyD4YRi/uFLgnrKZx+WZKzxguHc8Ot9y8ADM lou8FTYOda33XXwoiCBLgASQJX1y9+U= 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 C9560B80025; Sat, 4 Mar 2023 19:40:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCE5FC4339B; Sat, 4 Mar 2023 19:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677958801; bh=+0s3q5P93UqG6M+TlQeZxhgJ5LHMlSIa1orOsWRdKV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kziuyNZuajLhSjnjdZnm8IqkuHkf02BiKBZNeQC+XzR3qFQ2pMIvgf0HFTNa9ZvIU MiXIATlC5kNsCUH2IkV3+WpY+nfN1Et1hC77JdpBgeKoTLn/HW0Ki4lmvtt1zPIJNL hYKnvMg2LwM4bqzO6VLrDXgwcM5tSxgINdUbiPlqsy10b8o5tOTdX6A3qIKpyDDJcN zqsNJd4/fgyJ3UYj1S4AzQdJDyXfrsZxRc8y8fmEk6fxnmS6dBIJ1aLQGYaT6jB3P5 K4/8VIcDCSdpIZ11RUrXZOd8tV5KMmXciw/36gYjhopIQHHvdgbUSEye2jFUZsSZ9w JWulLNMHHCudA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Kefeng Wang , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/2] mm/damon/paddr: fix folio_size() call after folio_put() in damon_pa_young() Date: Sat, 4 Mar 2023 19:39:48 +0000 Message-Id: <20230304193949.296391-2-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-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 1qxzwcfqbmadynbnfyce6c4wfiun4agc X-Rspamd-Queue-Id: 3E3C74000B X-HE-Tag: 1677958804-776218 X-HE-Meta: U2FsdGVkX19J15jlbggTJluGJb5ddpOSt8380ySe9bmrv+qX+hRtxh+viCRbGmaFeB8fufc+ewWH8uSGEgBJclCOmjUmp/ImL4Drwf19HE2XVdHzK7aGHS1h7Fn6JN+39wy7GtQveL7m2yJyYgfRWawVsw6Cj0MZ/f8+UE1CGy94Oq64TVai62ry1CkA1QLCeepHUNhhSzBA3T+DjB/s0eti0G+mFMt2cSPkPkkpPZ3kJvQ8MtRXAj6iSHSKReL6x8bb5v0EkwazfKuawUqFdWLxe038F94zkb41jX6B6bD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/aAcxWg69LtW9csTSg== 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_young() is accessing a folio via folio_size() after folio_put() for the folio has invoked. Fix it. Fixes: 397b0c3a584b ("mm/damon/paddr: remove folio_sz field from damon_pa_access_chk_result") Cc: # 6.3.x Signed-off-by: SeongJae Park Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Kefeng Wang --- mm/damon/paddr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 3fda00a0f786..10f159b315ea 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -130,7 +130,6 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) accessed = false; else accessed = true; - folio_put(folio); goto out; } @@ -144,10 +143,10 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) if (need_lock) folio_unlock(folio); - folio_put(folio); out: *folio_sz = folio_size(folio); + folio_put(folio); return accessed; } 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/bVzFzc5t2DKGGaF3qZHxkGHYYg1sKQc14rju0o/i/XRR8L1YMZPCkboewn5ELEioe27SRwgpF4ZzxV3p2RtZvCvE3mYYo2dq4frylI599k9uJGjyyMPDfUREn46rz3W6rqFx1lTI43EvEjM+A2XezEmfgAe4AIAzaLMybFuACz4XUOED1KN0XOIk8+biqI+nUKSZR4BcfJE0uqnEbQ1s/lOXcf5rR94k37M1naCassdJM9paWEun0N05FCT1xlH3HUuOv4liRG5ABv/qIhw3ntkorxpDO9xqxOUAIA7Ms52V1LU6eiFm84WeVZJfdTorha500o5lShv5VPcj8fvD/u/2jJ1XWVIMu28eUHnLzx6/QAMz2xEsgZT38ghuAIOyjBFmdsAaN15XYPIS8dSUiziyWUWzkia2qSdisuzhqt9nzw13A6FxXs4zadsewtwahmu14HCq7ZNT4PQ1fMjvbVAv7hACtJR2a4wj6WC+Zn15O8/BT2LTxwOjrbfaLQKHZtNon4f0UJOigipwuo24kx5FqJdiB+yB31M4to7A1ybk9VPQ+c1Cy2dg5mvCeO8cOj5eR+DUz9a0+MuMpuo4iYK7Qho3uSsvipwG15jkiAbtnZcKKkxRZFY7tZqFfwIthtPj8tjOZN78ywXzyIuKP+WPA1pO0zGS5pkDzFSQhdrYm0lDzBT8mHh4SEFk+dWHImLQ+L6tdg0sRKpFTG7g+g4iyXIlVhmdpOLiiJMkkskcAtsU 9YieLrHS /oPbT4Qxa2HR1AkPzSm8Hs47K7sMvbsxDNMQaHqozrnaJbspB067dm4OZDgzzU0gt1USkx81Yu2NIw95gmntwfYj9YkbVhoMi7rOyhGbcc4WyehgUG+G3P1dHYJvgM8nu1PPY3AMDI3lHL+Ww+iApgoSVZu0seJo84vAKLXvGjOp2Z3ZxR/47KHc0gcwcvNP9Sb/9hybDikK6DMRbgOQMAFbJVNmm8/j3fMWl4cuqQFz7NFBpb1N/YQHx72v3Mhrit5/iFJ1+ZsrcEK/+obHh9ZLVEdpPs54XTW9B2+oKUXGe5pOdHit9VxCm6VPHwpvKZN/o0SPoP+itAi7jYiS6vi6yJCq3ROkDDGEdsdIAV//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; }