Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2340970pxj; Sun, 9 May 2021 23:59:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9UoQBel8+reUp+/PmPUtmAOeqCTapdN64UWGkiX2pgxc+kAJOI2Ycm5C93Gyry1ijrjSr X-Received: by 2002:a17:906:4d8d:: with SMTP id s13mr24051428eju.37.1620629988517; Sun, 09 May 2021 23:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620629988; cv=none; d=google.com; s=arc-20160816; b=w4ZNl/ZZ8h+wnqTx5n5NjOxfuN0zFfM+iD67r7i8s5KnyAemjnRvoV7x/yHt+/gxHb OSS7UoEs5WqVu4ZmWjlX71TMjzpoNa1Om8NhVvKY5zMK2Uype99ZvIrg2XAAeoaYnY4r pqjprwoV0MN2F0R3rvSExqbKU9ejux+gvcpoBNvw5YcBP4370/20AvOFHrF6RQ+INH4Y F04MFrd2s+5IWq2r+UM1J4QsWMYx5N+z9V3xWwdMYpYSod8W42Pjma7cjzHeIVE6exjY sTHI3p+fwb8p5LBqgGsW4fkL5qZ6kJc+T9x4jVUWVrV4GSLvimhhN9dxwJbUKmosUGyZ coug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=47zHQ8J92ft6mZ/StX/26FX/FA7T88lLZlW9A4AzZtk=; b=nYMj8Msj7ViduNMg1ZNFnWo2NkKCBx0LWOf03cryDypp4nWqUusFyesVNPJeVV0tUZ yjnEme4XLQ3Wlfs8S6K/Kk2aAIdOvXAT5hMt1cu20APVuhojpDX2+hJRmOLurR2PjLgj 547ZxZoqMCeXQdrpKxZY9CSV2ZOs4BHx14MDZpd7NaTUuiFJNYuzHLREys0wx6Kpv/xY J1GL9uXGTn97iiV9vFBwnJoCAxTNs64MbVkMmkY2+ETs+SN/owRy6uR6HWaJ+YdU83mq IRm0Qu/l9D+Nx95aj/LmkxrZnG3U6LyuQ30nmZdFwkTVJCYXRi2R49K+tyPc5r3FPpTk BPaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt25si4813864ejb.168.2021.05.09.23.59.25; Sun, 09 May 2021 23:59:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230050AbhEJG6S (ORCPT + 99 others); Mon, 10 May 2021 02:58:18 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:2425 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbhEJG6R (ORCPT ); Mon, 10 May 2021 02:58:17 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FdsHC2SwVzCqrG; Mon, 10 May 2021 14:54:31 +0800 (CST) Received: from [10.174.176.232] (10.174.176.232) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Mon, 10 May 2021 14:57:06 +0800 Subject: Re: [PATCH] ksm: Revert "use GET_KSM_PAGE_NOLOCK to get ksm page in remove_rmap_item_from_tree()" To: Hugh Dickins , Andrew Morton CC: , References: From: Miaohe Lin Message-ID: <0e04877c-5b2d-b810-7464-108e793b84d3@huawei.com> Date: Mon, 10 May 2021 14:57:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.232] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/5/10 13:59, Hugh Dickins wrote: > This reverts commit 3e96b6a2e9ad929a3230a22f4d64a74671a0720b. > General Protection Fault in rmap_walk_ksm() under memory pressure: > remove_rmap_item_from_tree() needs to take page lock, of course. > I'am really sorry about it! And many thanks for this bugfix! It seems rmap_walk_ksm() relies on the page lock to protect against concurrent modifications to that page's node of the stable tree. Could you please add a comment in remove_rmap_item_from_tree() to clarify this in case similar trouble again? Many thanks! > Signed-off-by: Hugh Dickins > --- > > mm/ksm.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > --- 5.13-rc1/mm/ksm.c 2021-05-09 17:03:44.010422188 -0700 > +++ linux/mm/ksm.c 2021-05-09 22:12:39.403008350 -0700 > @@ -776,11 +776,12 @@ static void remove_rmap_item_from_tree(s > struct page *page; > > stable_node = rmap_item->head; > - page = get_ksm_page(stable_node, GET_KSM_PAGE_NOLOCK); > + page = get_ksm_page(stable_node, GET_KSM_PAGE_LOCK); > if (!page) > goto out; > > hlist_del(&rmap_item->hlist); > + unlock_page(page); > put_page(page); > > if (!hlist_empty(&stable_node->hlist)) > . >