Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp580516ybp; Fri, 4 Oct 2019 01:24:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhVpl2qDW1xTezADfKbdwrr7ojYqMq5AldE9ptu5NbOZLuew0d+eohIlr8FHFm36OttRcK X-Received: by 2002:a17:906:d154:: with SMTP id br20mr11440482ejb.79.1570177490113; Fri, 04 Oct 2019 01:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570177490; cv=none; d=google.com; s=arc-20160816; b=liZumCx6ujG8F7afb+mRS6HclbFSjNwrRpqrn+5QFbl60tXkKqMJlSjjvnPU3eIyIY pI/aoOCiiE5MWuUjASbngkjAB2IbcAK55rxUeGJq9NH6BYuRMVuQZqKmOt5DyOAKN623 KZcT+rQqdzBYRQpEwv9GSGGOodsFK9dbt8ADdumaZxY6xsuL1Ng1K4jeEHqHAijF8OSy SBFC8yD+7+sN7pingno9MDuEbBOZel7YCZgqGUwZnxlMyy/FUGNZSSzZFRorF3m3EFVO 5+rulsf3p8E+MR7fblmDSeDIzzAo3aUNtNiJ7j9lP82PNZ4lZck8IVVgNQBJq6V76tZC /psg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=/Xhd2rQny2kWYYvngVGyhAop6Xz98CNd6Mmi7mkC75Y=; b=T3Sx9bvdYD7F3/9ezIp9dSfW/lxMzEe+pXChWiS8cqxPenmP5WFkxvJkjUvlsw/eWj TljPqnVZZA7ExAD/gzmNwbDYjRQ4QgEBE5pNWN50wjsBCK+uEYiVXE8GLjWAABHN0eRa nBFuYHMGcqgQfOT3/yOr1spIrMH5eRy52Glcn0d/iwsDTbmM8jX7V8quxIib0Dcogru1 oNQfk9O49pIYvd28nw/Dhs5KBNfH7WAD0pZB5daGny7dvec5rfvmsAjN5xKjpn2HxVs3 TN4fYxhUtsXHBMIz5wYLXiTLaqTa+hqshdY+1f28ywqv851rD3dtBsyqVr46XdLYbNWV qlEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t26si2357587eju.238.2019.10.04.01.24.25; Fri, 04 Oct 2019 01:24:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730607AbfJDHiG (ORCPT + 99 others); Fri, 4 Oct 2019 03:38:06 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:27739 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727326AbfJDHiF (ORCPT ); Fri, 4 Oct 2019 03:38:05 -0400 X-UUID: 4ac84daae92845f4b4b3b9b40615446e-20191004 X-UUID: 4ac84daae92845f4b4b3b9b40615446e-20191004 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 482322489; Fri, 04 Oct 2019 15:37:57 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 4 Oct 2019 15:37:55 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 4 Oct 2019 15:37:55 +0800 From: Miles Chen To: Andrew Morton CC: , , , , Miles Chen , Vlastimil Babka , Michal Hocko Subject: [PATCH] mm/page_owner: fix incorrect looping in __set_page_owner_handle() Date: Fri, 4 Oct 2019 15:37:55 +0800 Message-ID: <20191004073755.3228-1-miles.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In __set_page_owner_handle(), we should loop over page [0...(1 << order) - 1] and setup their page_owner structures. Currently, __set_page_owner_handle() update page_ext at the end of the loop, sets the page_owner of (page + 0) twice and misses the page_owner of (page + (1 << order) - 1). Fix it by updating the page_ext at the start of the loop. In i == 0 case: for (i = 0; i < (1 << order); i++) { page_owner = get_page_owner(page_ext); <- page_ext belongs to page + 0 ... page_ext = lookup_page_ext(page + i); <- lookup_page_ext(page + 0) } Cc: Andrew Morton Cc: Vlastimil Babka Cc: Michal Hocko Signed-off-by: Miles Chen Fixes: 7e2f2a0cd17c ("mm, page_owner: record page owner for each subpage") --- mm/page_owner.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/page_owner.c b/mm/page_owner.c index dee931184788..110c3e1987f2 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -178,6 +178,7 @@ static inline void __set_page_owner_handle(struct page *page, int i; for (i = 0; i < (1 << order); i++) { + page_ext = lookup_page_ext(page + i); page_owner = get_page_owner(page_ext); page_owner->handle = handle; page_owner->order = order; @@ -185,8 +186,6 @@ static inline void __set_page_owner_handle(struct page *page, page_owner->last_migrate_reason = -1; __set_bit(PAGE_EXT_OWNER, &page_ext->flags); __set_bit(PAGE_EXT_OWNER_ACTIVE, &page_ext->flags); - - page_ext = lookup_page_ext(page + i); } } -- 2.18.0