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; }