Received: by 10.213.65.68 with SMTP id h4csp1064326imn; Wed, 21 Mar 2018 01:28:52 -0700 (PDT) X-Google-Smtp-Source: AG47ELuLhYPxaJ6PNYqO/UMFBahAE/6sJhZTsm3uvR8tY3AlI6naR65qAIb9LtBqY/i9TZWagvo1 X-Received: by 10.99.123.19 with SMTP id w19mr13835966pgc.405.1521620932103; Wed, 21 Mar 2018 01:28:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521620932; cv=none; d=google.com; s=arc-20160816; b=el5JqWaqNBMZI7LGy/NOdx1Q1dJKbWEILPvr3ORPAifpSpSgKAww3XVUMf6bk14MM4 rH9klw+bU6enQEurg1y7/zS3WTlKRxo9ioW5ieQuPHz7Fyp5pBfvcKk6Go39J7tmQv4z ojIDbmEH+hOb/H+xziW9NmGaV1wygwC/QDf5hGlxGNyua8VR8kOIeEdl7hMTIajB7P8I PrpNRGqtwJUKUUfAAYcxuUdspwAjqSFA8QfWI4OVRy/vz7PzezuHW9GIiL0rIz1N29GN uTFDzTOnh3QYI2D/lZ0CH3DMX2I/Agqhnv9lvOMg1eXbCBAymfw3nxji+m26Jy59SLP4 oTmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=//K9gozBWpX1+aMeaM1vIXNyuWzLgO46VMGLC5UYIrU=; b=QYGtjAPUL6YQAqYPSqZbxmuQqYWUq5H6AgicGN7gJJg03LANFNZucItZQNNDDPVRda E64WTR7xBz0pI6jQHlrZKj38qIwbmgtP/sbhYwYh+hNMkMjp+BbmZJR9TyPBx3VJSqHo RQL3QWKx5V7VWp1hk+X3L6elUBWkccpthwyI+m60BuoyYsmULEolIuu/m0znDNYxQ/TS mMTx1ZDcB1+R8FYTqW6dr0P8JFOj0mwVQRaNicCpDpNgqg2fhqUteocCjP1vyaygeuJj lD24ArUvjSLWdgHioXuHn/yoiw6nuNn54flh5O/Q7ZcxvsVpUkKz7AmlTd7zBzFnwYgc g7FA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 38-v6si3409598pln.397.2018.03.21.01.28.38; Wed, 21 Mar 2018 01:28:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751995AbeCUI1X (ORCPT + 99 others); Wed, 21 Mar 2018 04:27:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:47018 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751515AbeCUI1T (ORCPT ); Wed, 21 Mar 2018 04:27:19 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 445F2AE46; Wed, 21 Mar 2018 08:27:18 +0000 (UTC) Subject: Re: [PATCH 1/1] mm/page_owner: fix recursion bug after changing skip entries To: Maninder Singh , akpm@linux-foundation.org, mhocko@suse.com, osalvador@techadventures.net, gregkh@linuxfoundation.org, ayush.m@samsung.com, guptap@codeaurora.org, vinmenon@codeaurora.org, gomonovych@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, a.sahrawat@samsung.com, pankaj.m@samsung.com, Vaneet Narang References: <1521607043-34670-1-git-send-email-maninder1.s@samsung.com> From: Vlastimil Babka Message-ID: <40171c50-4466-6589-3968-024f936e5c7a@suse.cz> Date: Wed, 21 Mar 2018 09:25:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1521607043-34670-1-git-send-email-maninder1.s@samsung.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/21/2018 05:37 AM, Maninder Singh wrote: > This patch fixes "5f48f0bd4e368425db4424b9afd1bd251d32367a". > (mm, page_owner: skip unnecessary stack_trace entries) > > Because if we skip first two entries then logic of checking count > value as 2 for recursion is broken and code will go in one depth > recursion. > > so we need to check only one call of _RET_IP(__set_page_owner) > while checking for recursion. > > Current Backtrace while checking for recursion:- > > (save_stack) from (__set_page_owner) // (But recursion returns true here) > (__set_page_owner) from (get_page_from_freelist) > (get_page_from_freelist) from (__alloc_pages_nodemask) > (__alloc_pages_nodemask) from (depot_save_stack) > (depot_save_stack) from (save_stack) // recursion should return true here > (save_stack) from (__set_page_owner) > (__set_page_owner) from (get_page_from_freelist) > (get_page_from_freelist) from (__alloc_pages_nodemask+) > (__alloc_pages_nodemask) from (depot_save_stack) > (depot_save_stack) from (save_stack) > (save_stack) from (__set_page_owner) > (__set_page_owner) from (get_page_from_freelist) > > Correct Backtrace with fix: > > (save_stack) from (__set_page_owner) // recursion returned true here > (__set_page_owner) from (get_page_from_freelist) > (get_page_from_freelist) from (__alloc_pages_nodemask+) > (__alloc_pages_nodemask) from (depot_save_stack) > (depot_save_stack) from (save_stack) > (save_stack) from (__set_page_owner) > (__set_page_owner) from (get_page_from_freelist) > > Signed-off-by: Maninder Singh > Signed-off-by: Vaneet Narang Fixes: 5f48f0bd4e36 ("mm, page_owner: skip unnecessary stack_trace entries") Good catch. Acked-by: Vlastimil Babka > --- > mm/page_owner.c | 6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/mm/page_owner.c b/mm/page_owner.c > index 8592543..46ab1c4 100644 > --- a/mm/page_owner.c > +++ b/mm/page_owner.c > @@ -123,13 +123,13 @@ void __reset_page_owner(struct page *page, unsigned int order) > static inline bool check_recursive_alloc(struct stack_trace *trace, > unsigned long ip) > { > - int i, count; > + int i; > > if (!trace->nr_entries) > return false; > > - for (i = 0, count = 0; i < trace->nr_entries; i++) { > - if (trace->entries[i] == ip && ++count == 2) > + for (i = 0; i < trace->nr_entries; i++) { > + if (trace->entries[i] == ip) > return true; > } > >