Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753905AbcDKOvv (ORCPT ); Mon, 11 Apr 2016 10:51:51 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:36015 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753137AbcDKOvt convert rfc822-to-8bit (ORCPT ); Mon, 11 Apr 2016 10:51:49 -0400 MIME-Version: 1.0 In-Reply-To: References: <4f6880ee0c1545b3ae9c25cfe86a879d724c4e7b.1457949315.git.glider@google.com> <20160411074452.GC26116@js1304-P5Q-DELUXE> Date: Mon, 11 Apr 2016 16:51:47 +0200 Message-ID: Subject: Re: [PATCH v7 5/7] mm, kasan: Stackdepot implementation. Enable stackdepot for SLAB From: Alexander Potapenko To: Joonsoo Kim Cc: Andrey Konovalov , Christoph Lameter , Dmitriy Vyukov , Andrew Morton , Andrey Ryabinin , Steven Rostedt , Kostya Serebryany , kasan-dev , LKML , Linux Memory Management List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1973 Lines: 65 On Mon, Apr 11, 2016 at 4:39 PM, Alexander Potapenko wrote: > On Mon, Apr 11, 2016 at 9:44 AM, Joonsoo Kim wrote: >> On Mon, Mar 14, 2016 at 11:43:43AM +0100, Alexander Potapenko wrote: >>> +depot_stack_handle_t depot_save_stack(struct stack_trace *trace, >>> + gfp_t alloc_flags) >>> +{ >>> + u32 hash; >>> + depot_stack_handle_t retval = 0; >>> + struct stack_record *found = NULL, **bucket; >>> + unsigned long flags; >>> + struct page *page = NULL; >>> + void *prealloc = NULL; >>> + bool *rec; >>> + >>> + if (unlikely(trace->nr_entries == 0)) >>> + goto fast_exit; >>> + >>> + rec = this_cpu_ptr(&depot_recursion); >>> + /* Don't store the stack if we've been called recursively. */ >>> + if (unlikely(*rec)) >>> + goto fast_exit; >>> + *rec = true; >>> + >>> + hash = hash_stack(trace->entries, trace->nr_entries); >>> + /* Bad luck, we won't store this stack. */ >>> + if (hash == 0) >>> + goto exit; >> >> Hello, >> >> why is hash == 0 skipped? >> >> Thanks. > We have to keep a special value to distinguish allocations for which > we don't have the stack trace for some reason. > Making 0 such a value seems natural. Well, the above statement is false. Because we only compare the hash to the records that are already in the depot, there's no point in reserving this value. > > -- > Alexander Potapenko > Software Engineer > > Google Germany GmbH > Erika-Mann-Straße, 33 > 80636 München > > Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle > Registergericht und -nummer: Hamburg, HRB 86891 > Sitz der Gesellschaft: Hamburg -- Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Straße, 33 80636 München Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg