From patchwork Mon Nov 5 22:47:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 1700721 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 45CF8DF2AB for ; Mon, 5 Nov 2012 22:50:49 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TVVSl-0000PO-PA; Mon, 05 Nov 2012 22:48:12 +0000 Received: from mail-da0-f49.google.com ([209.85.210.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TVVSD-0000JF-1d for linux-arm-kernel@lists.infradead.org; Mon, 05 Nov 2012 22:47:38 +0000 Received: by mail-da0-f49.google.com with SMTP id q27so2653738daj.36 for ; Mon, 05 Nov 2012 14:47:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=KhM51IoX/o53wwywoSj3nTglzSRnF8pnxair4tdjvHI=; b=HFqY9qMdauQ47zYh8g4nyssr3mmZf+hVzCY+ZD8LgxdRmfUmQTvs7mLZP8JyNqTHng +N83Kg/lq8g5qzKmtOQkrYi+uNWI4lzhqhZmW/Av0SZGBfSyWB92DEUgynVNaBEAFYv4 2AAoJ1XnAnd8/0LkJvH2K/QK1nz5KtcaFGjL/obg7pU1DXNr4fY6iKRkXVKUWK/36pJ3 A7c51FpE51O4AbAlbQPUucG5OwnumeEXrmdvLvwCxhB2k53flgNiyvX7ueF58fv93Y5K 5TtFO+dqpr93Iw9fTgf7LDvy5K+Bz+QG8hHW7M9J0frxwSOmw8h5eFF5/sr1/LT6TluO LRCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=KhM51IoX/o53wwywoSj3nTglzSRnF8pnxair4tdjvHI=; b=ThKvUR3lOtwhdrBuZtYlJR8Jh8W5XPtGDlOmNaSQL7rHPQrf9WdmuFo3C6mY98tbx/ 3v27zqKslTSvvJ7UkgVUqzOt3ZcEf+6nLvoNIPUV359p3LURKZkrabYGXtltIuRe56YP fizsmOH/3tRjx00CEKB3YUaeIawZBTwcH9QZpAjBZw2JpySHeRBpCglX3/RGMPgPD9/7 ONgsO4OEmp70UrRphFpyDAs/6ClPraZ8dglOjeqTDCad4+F0lwZy98HG19nYNzqtRVMN XPlPwdGidho0C+Vnn3gyrj/TunJsSQrTZdLQQ2T/ZnMmKkEUox9ItMGWFXibuY2gFxwR B6zQ== Received: by 10.66.78.231 with SMTP id e7mr32396375pax.44.1352155656174; Mon, 05 Nov 2012 14:47:36 -0800 (PST) Received: from studio.mtv.corp.google.com (studio.mtv.corp.google.com [172.17.131.106]) by mx.google.com with ESMTPS id jx4sm11201653pbc.27.2012.11.05.14.47.34 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Nov 2012 14:47:35 -0800 (PST) From: Michel Lespinasse To: Andrew Morton , Rik van Riel , Hugh Dickins , linux-kernel@vger.kernel.org, Russell King , Ralf Baechle , Paul Mundt , "David S. Miller" , Chris Metcalf , x86@kernel.org, William Irwin Subject: [PATCH 03/16] mm: check rb_subtree_gap correctness Date: Mon, 5 Nov 2012 14:47:00 -0800 Message-Id: <1352155633-8648-4-git-send-email-walken@google.com> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1352155633-8648-1-git-send-email-walken@google.com> References: <1352155633-8648-1-git-send-email-walken@google.com> X-Gm-Message-State: ALoCoQkubws5MTx44cfv+XYBwk78+QruoYLsG5VZCj9Ju7eg3vFbY7Z8m22n17zKN+3Uhiz9VBE/Iu1bRUDPjIWkUltOVq0k+XVUOdCNrjOA83t2dlKt/QUW5D3lbeXxb7RjdVu0cjBqXBiL7YgZpYHurHJLaHGPBOgM0vnilXVyviy2KORQ2WS+3crFqHdMNvY/Tncx4Ps6eVNwTBa5u7WKgphbwn9HOw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121105_174737_421700_BE9498CB X-CRM114-Status: GOOD ( 13.69 ) X-Spam-Score: -0.4 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.49 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: sparclinux@vger.kernel.org, linux-mm@kvack.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When CONFIG_DEBUG_VM_RB is enabled, check that rb_subtree_gap is correctly set for every vma and that mm->highest_vm_end is also correct. Also add an explicit 'bug' variable to track if browse_rb() detected any invalid condition. Signed-off-by: Michel Lespinasse Reviewed-by: Rik van Riel --- mm/mmap.c | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 2de8bcfe859d..769a09cc71af 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -365,7 +365,7 @@ static void vma_rb_erase(struct vm_area_struct *vma, struct rb_root *root) #ifdef CONFIG_DEBUG_VM_RB static int browse_rb(struct rb_root *root) { - int i = 0, j; + int i = 0, j, bug = 0; struct rb_node *nd, *pn = NULL; unsigned long prev = 0, pend = 0; @@ -373,29 +373,33 @@ static int browse_rb(struct rb_root *root) struct vm_area_struct *vma; vma = rb_entry(nd, struct vm_area_struct, vm_rb); if (vma->vm_start < prev) - printk("vm_start %lx prev %lx\n", vma->vm_start, prev), i = -1; + printk("vm_start %lx prev %lx\n", vma->vm_start, prev), bug = 1; if (vma->vm_start < pend) - printk("vm_start %lx pend %lx\n", vma->vm_start, pend); + printk("vm_start %lx pend %lx\n", vma->vm_start, pend), bug = 1; if (vma->vm_start > vma->vm_end) - printk("vm_end %lx < vm_start %lx\n", vma->vm_end, vma->vm_start); + printk("vm_end %lx < vm_start %lx\n", vma->vm_end, vma->vm_start), bug = 1; + if (vma->rb_subtree_gap != vma_compute_subtree_gap(vma)) + printk("free gap %lx, correct %lx\n", + vma->rb_subtree_gap, + vma_compute_subtree_gap(vma)), bug = 1; i++; pn = nd; prev = vma->vm_start; pend = vma->vm_end; } j = 0; - for (nd = pn; nd; nd = rb_prev(nd)) { + for (nd = pn; nd; nd = rb_prev(nd)) j++; - } if (i != j) - printk("backwards %d, forwards %d\n", j, i), i = 0; - return i; + printk("backwards %d, forwards %d\n", j, i), bug = 1; + return bug ? -1 : i; } void validate_mm(struct mm_struct *mm) { int bug = 0; int i = 0; + unsigned long highest_address = 0; struct vm_area_struct *vma = mm->mmap; while (vma) { struct anon_vma_chain *avc; @@ -403,11 +407,15 @@ void validate_mm(struct mm_struct *mm) list_for_each_entry(avc, &vma->anon_vma_chain, same_vma) anon_vma_interval_tree_verify(avc); anon_vma_unlock(vma->anon_vma); + highest_address = vma->vm_end; vma = vma->vm_next; i++; } if (i != mm->map_count) printk("map_count %d vm_next %d\n", mm->map_count, i), bug = 1; + if (highest_address != mm->highest_vm_end) + printk("mm->highest_vm_end %lx, found %lx\n", + mm->highest_vm_end, highest_address), bug = 1; i = browse_rb(&mm->mm_rb); if (i != mm->map_count) printk("map_count %d rb %d\n", mm->map_count, i), bug = 1;