Message ID | 20230808020917.2230692-1-fengwei.yin@intel.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2207478vqr; Tue, 8 Aug 2023 08:40:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2EWBbFWuK+1qX8d6hxSvlbjtHx0JfaK6vPenh3iIFTHp1TEAKy0cJFfHUCMDlNNBfNvUp X-Received: by 2002:a05:6a00:1409:b0:668:83b7:fd02 with SMTP id l9-20020a056a00140900b0066883b7fd02mr11833157pfu.31.1691509259403; Tue, 08 Aug 2023 08:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691509259; cv=none; d=google.com; s=arc-20160816; b=XZC4mcAzaG2ora9Fv9OWoLE4HkgNZ9/cl/AkJazwpit+gZWqZ7c4nAlWnue3FtYZyv q7wLVepEgB1HTrJCI3ymuN8T3SJiQN3GZwnxIXkWsW++4az93uZmZUGIPu3ZkPbRDqA7 /zZVivHHAWOJWN3/jPIjc9yw1okFpUBP5wFrAJ0/Mqq5D+ZzPzpiukZh1/oCzxQfGZqu yCH5Zi5c9fmRnk8nMuFiXRBYrhy0AZF4cu7j7tx5P1zVl6RZMAFoCRLqvlWEGQ/P0yE+ BOXw8qJe2mRDgpSH6RGllID6DLgj/8fDiV7gGQsmQKgScfarGTQRjGG0/nxeoaZSM+uT cEZQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=nxIcTJJIcuoAgpAn/H1eWO64VvlSIo1Dt/soZB9CeDA=; fh=LgrQy7mqd4cTuAw7dlguzqzf4K4OZS27s5hhhI8E0EA=; b=eD64ViyFgOcfrengAbedeeNGQUTFo31S84BzD1wE4Zun8Nm0enHuuczIYQfKRyq4DZ fZe5D1qUN86Jj2BKugEDSE+nqXmoXKNDb6c/FPpvCofP6eB1XUKedke2lkM3oVkCnU07 4FgvV0SM1ZfVzygmAYown/nwcdTTpXBcmUtZrch0+B3t8B6xDRmSURsoG1ZbwfjyA6YE W70pln02fYAFIHzQvRSUehAaWGo02WTyxywjm5TFEqizjsmpC6V0sZIUi5FHTCZy8QeO jhRIZ4KhK/sr3YwNUMKXoo5HW2UC0DsGhhnbO+Iu4wMr47/tI0l2W53NWXQ+Q4ocIcZH 354A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DcCY8Bn9; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 28-20020a63155c000000b0055c7da0216dsi7204402pgv.635.2023.08.08.08.40.46; Tue, 08 Aug 2023 08:40:59 -0700 (PDT) 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=@intel.com header.s=Intel header.b=DcCY8Bn9; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230155AbjHHCKl (ORCPT <rfc822;aaronkmseo@gmail.com> + 99 others); Mon, 7 Aug 2023 22:10:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjHHCKk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 7 Aug 2023 22:10:40 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61F471705; Mon, 7 Aug 2023 19:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691460639; x=1722996639; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=uG3NDhRuxMTWT3J/vbhAok1ojRTKKVWwCGRMvfusbWg=; b=DcCY8Bn9iHb5VsmXZA25CMrZDFlZ6g2R15J4fM825oa8AdoVmmf7MaOG qMj3CB11vvBap5fLTZEBYFNOWa28WBWy3vtoG0M41D1IkpUqEo/diM/Ro 1PHeTPaCcPmn2hQnnyaLJuP8Zc5BIVTyFYv5wIfOeB2r8e9g/QM7JBJOz /D735laJ1QTvbD8etAJDItBT9TzRuGNripRDz//qvMzm5j1ca5pckwR5a zUGCBDb8C89DS8TbDJdtooeXY7a2U4XLnOLQA3v+7xcz9HDfZvTn2bKAX ZS134BT9366UIwBmav4NZ9a88Sq/oeVYx/lOhcf7xdgJQtudx6gylzmp8 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="360786307" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="360786307" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2023 19:10:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="1061813239" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="1061813239" Received: from fyin-dev.sh.intel.com ([10.239.159.32]) by fmsmga005.fm.intel.com with ESMTP; 07 Aug 2023 19:10:35 -0700 From: Yin Fengwei <fengwei.yin@intel.com> To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, vishal.moola@gmail.com, wangkefeng.wang@huawei.com, minchan@kernel.org, yuzhao@google.com, david@redhat.com, ryan.roberts@arm.com, shy828301@gmail.com Cc: fengwei.yin@intel.com Subject: [PATCH v2 0/3] don't use mapcount() to check large folio sharing Date: Tue, 8 Aug 2023 10:09:14 +0800 Message-Id: <20230808020917.2230692-1-fengwei.yin@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773628811776451458 X-GMAIL-MSGID: 1773676013159057813 |
Series |
don't use mapcount() to check large folio sharing
|
|
Message
Yin Fengwei
Aug. 8, 2023, 2:09 a.m. UTC
In madvise_cold_or_pageout_pte_range() and madvise_free_pte_range(), folio_mapcount() is used to check whether the folio is shared. But it's not correct as folio_mapcount() returns total mapcount of large folio. Use folio_estimated_sharers() here as the estimated number is enough. This patchset will fix the cases: User space application call madvise() with MADV_FREE, MADV_COLD and MADV_PAGEOUT for specific address range. There are THP mapped to the range. Without the patchset, the THP is skipped. With the patch, the THP will be split and handled accordingly. David reported the cow self test skip some cases because of MADV_PAGEOUT skip THP: https://lore.kernel.org/linux-mm/9e92e42d-488f-47db-ac9d-75b24cd0d037@intel.com/T/#mbf0f2ec7fbe45da47526de1d7036183981691e81 and I confirmed this patchset make it work again. Changelog from v1: - Avoid two Fixes tags make backport harder. Thank Andrew for pointing this out. - Add note section to mention this is a temporary fix which is fine to reduce user-visble effects. For long term fix, we should wait for David's solution. Thank Ryan and David for pointing this out. - Spell user-visible effects out. Then people could decide whether these patches are necessary for stable branch. Thank Andrew for pointing this out. V1: https://lore.kernel.org/linux-mm/9e92e42d-488f-47db-ac9d-75b24cd0d037@intel.com/T/#med74caad0cbd0049641cfddc5b9fe793b4b50276 Yin Fengwei (3): madvise:madvise_cold_or_pageout_pte_range(): don't use mapcount() against large folio for sharing check madvise:madvise_free_huge_pmd(): don't use mapcount() against large folio for sharing check madvise:madvise_free_pte_range(): don't use mapcount() against large folio for sharing check mm/huge_memory.c | 2 +- mm/madvise.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
Comments
On 8/8/2023 10:43 AM, Yu Zhao wrote: > On Mon, Aug 7, 2023 at 8:10 PM Yin Fengwei <fengwei.yin@intel.com> wrote: >> >> In madvise_cold_or_pageout_pte_range() and madvise_free_pte_range(), >> folio_mapcount() is used to check whether the folio is shared. But it's >> not correct as folio_mapcount() returns total mapcount of large folio. >> >> Use folio_estimated_sharers() here as the estimated number is enough. >> >> >> This patchset will fix the cases: >> User space application call madvise() with MADV_FREE, MADV_COLD and >> MADV_PAGEOUT for specific address range. There are THP mapped to the >> range. Without the patchset, the THP is skipped. With the patch, the >> THP will be split and handled accordingly. >> >> David reported the cow self test skip some cases because of >> MADV_PAGEOUT skip THP: >> https://lore.kernel.org/linux-mm/9e92e42d-488f-47db-ac9d-75b24cd0d037@intel.com/T/#mbf0f2ec7fbe45da47526de1d7036183981691e81 >> and I confirmed this patchset make it work again. >> >> >> Changelog from v1: >> - Avoid two Fixes tags make backport harder. Thank Andrew for pointing >> this out. >> >> - Add note section to mention this is a temporary fix which is fine >> to reduce user-visble effects. For long term fix, we should wait for >> David's solution. Thank Ryan and David for pointing this out. >> >> - Spell user-visible effects out. Then people could decide whether >> these patches are necessary for stable branch. Thank Andrew for >> pointing this out. > > LGTM, thank you. Thanks a lot for looking at this patchset. Regards Yin, Fengwei