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: 64263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1064260wrd; Sat, 4 Mar 2023 11:47:14 -0800 (PST) X-Google-Smtp-Source: AK7set99d212yOoGBLVyeJOz41lXshN467L3y1hPMPl2eEd2fYOeJpAuLt1jBYD6gMxVipke2oAy X-Received: by 2002:a17:90b:4c43:b0:237:cbcb:efba with SMTP id np3-20020a17090b4c4300b00237cbcbefbamr6578142pjb.17.1677959234659; Sat, 04 Mar 2023 11:47:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677959234; cv=none; d=google.com; s=arc-20160816; b=RtxMGEo7WJtqoS0WnZ+ZlpaPJ5vX3mH8hfDmxsbERYFrkrHmK3auIj6moHsM7ho5vp dLdkHyxYjdn9kWJ7YBC+oZaFVWGH5oIEAqx+uDw5CpdMnkEWTf0R/a2SAyMMDTszfb56 ovoupDSU3JXyGmGs1/tVN/0q8LmwUvY298wujDJ6iOOyGmgRY84bd44IOdYGkY3iOisX GjJ11byubVUuuDqs9Dd6YCBuRrXP22qcEg54ZhcUPe9fyHVmlvXX2zS89lGDL4WPUk9+ Jjvx5kraFUwOxHU6kJD2gqkv+Ya6ahWHwqw3XbsFyNuddjHcGkkweHa4VlHXPQbiVR7N quig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=klm7pnrwFn/X2JkkrxJx+ttziTax9gOlsMmofh2ZMFw=; b=LBzOCLLMAsEQHLRBI8WTiO6qPtQ3ac7C+TGRheI8Bn6tqyJExDDF4PWVUSrkNFSKqq f9fSFHi41WIFRzKwtOBx6U6CbBHEAxzfdL1mP8+ArJsix6zARH4/S7QEgjWLkPh3Ib7k iBWm1qPz67vAlFxHdx/bLQGH+c/NcwbljXIWpNYP/6R7OMmGFYOLX6VRu2gp7FyMHceu bS5ghMhhzL+BmWe6gYgY5Oh0cFSxddgFbQUreSpkBXAm/Sa4f7fU3G75Zfw8htoRCGkj NQnGBzqUlTeIs9Fb+kP5l6jA85QoxhPlzQM1dhkdjYA9YQ9IA2j4kx+86tE6NhsDNWb8 iNfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kziuyNZu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a17090a3d0200b00233d3b31b61si7562733pjc.140.2023.03.04.11.47.02; Sat, 04 Mar 2023 11:47:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kziuyNZu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229567AbjCDTkG (ORCPT + 99 others); Sat, 4 Mar 2023 14:40:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjCDTkD (ORCPT ); Sat, 4 Mar 2023 14:40:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82014CC34; Sat, 4 Mar 2023 11:40:02 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 0D2E760A65; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759467782544516227?= X-GMAIL-MSGID: =?utf-8?q?1759467782544516227?= 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: 64264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1064273wrd; Sat, 4 Mar 2023 11:47:16 -0800 (PST) X-Google-Smtp-Source: AK7set+3x6ddciznaAoZIvsKc69XI1ymW+fuW67217RHwnqcFdKiop3Beg34FbONyKnw3V5ikV7N X-Received: by 2002:a17:90b:1c88:b0:233:f98a:8513 with SMTP id oo8-20020a17090b1c8800b00233f98a8513mr6654039pjb.8.1677959236533; Sat, 04 Mar 2023 11:47:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677959236; cv=none; d=google.com; s=arc-20160816; b=RZ7AaW3LizX9Kk6BtWHGRW9H9pAj5rDUXTn3OZSQ8XNfUCjyJOOEWOj9wLjwrSyVEt Q+8opj49scw3PxWLZiDzXo3DqaHeaFb6ZSzoepw+atqu++6eJ0unT0lzNFxmyigj/ymi QNIomVw6CkzpR4s+yn+GVlwf/+KZ86s3YNBM3jQ5R9vIWYb5TzpJ+z3Z7dw09N/bpjhi H0FfzAc2GYJgFyelIELRzyAhLzS3WiVCbepnnIw0aJXYII9BX3hmYwE8mfA9k0x79uMO sfL+iNKJzJRFKHcLIi8oIdHJesG2qLRGnH7lW+Qi/imujNeF910tGErOvvg/S6v9WX2A +x5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l8XI5QpQKoTIzhmBo1OGgSbthQInK2OIZNWIDSd9e6o=; b=q5g/WiEQcxQLCMULI3KAOTc5M7oyyiimVAitXK/QSdm/K44zMj3egrzz/UOyXeWdwF 1kWQuzVUHFTiuRQR8t2NseMl2CgadppdzLoXVCInrljYBdncYhWdAlK1NTt6VyQK59tI u/F/0iP+TxsX35wUwyiBrXDIevNjLcXB27srHTM5jnU55r4rvo5naip7P54GNSWFGbFX OcsXaML1YD2APB7Up806oOdm3UcRhC6kya9DN4yjuLZcKd/EfW7UVBAwcp0igAnk7aZn 1z/K4xJaXlBY54Ikobf1/cU16YwekFlSqcmVnaJ8haMZ1qQvihmOKLH8KfNV2Pa6bBiK WRGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=e3nKr5Xs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i11-20020a17090ad34b00b00237c54c1643si5297248pjx.139.2023.03.04.11.47.04; Sat, 04 Mar 2023 11:47:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=e3nKr5Xs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbjCDTkI (ORCPT + 99 others); Sat, 4 Mar 2023 14:40:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbjCDTkE (ORCPT ); Sat, 4 Mar 2023 14:40:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41EE3CDC4; Sat, 4 Mar 2023 11:40:03 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id D2DAC60A55; Sat, 4 Mar 2023 19:40:02 +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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759467784092534152?= X-GMAIL-MSGID: =?utf-8?q?1759467784092534152?= 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) --- 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; }