From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753976AbdHUNbC convert rfc822-to-8bit (ORCPT ); Mon, 21 Aug 2017 09:31:02 -0400 Received: from mout.gmx.net ([212.227.17.21]:50529 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753840AbdHUNa7 (ORCPT ); Mon, 21 Aug 2017 09:30:59 -0400 Message-ID: <1503322229.25589.183.camel@gmx.de> Subject: Re: [rfc patch] sched/topology: fix domain reconstruction memory leakage From: Mike Galbraith To: Peter Zijlstra Cc: Ingo Molnar , LKML Date: Mon, 21 Aug 2017 15:30:29 +0200 In-Reply-To: <20170821081615.cpjmas4x5p7pcrbh@hirez.programming.kicks-ass.net> References: <1503123049.5112.49.camel@gmx.de> <20170821081615.cpjmas4x5p7pcrbh@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 Mime-Version: 1.0 Content-Transfer-Encoding: 8BIT X-Provags-ID: V03:K0:NOkRhpBnZO9oHSsh0GB5j4kqn0LOZjZueUj8ruamv5RM4+BeDkB gVBaAZEuJ08NL4zt2tHBrJ2Z6/S4LpI4tacs3S5JgXoay8hL5YcHlTYejU/nRB4YQq8JQlG BpP0omSpnXioafGgJ2ly5FWXjjkCWFta5IRMFCIE04sXpJWjHtTfmTSulyiX3QTsh6w5oiN rIYXvXsujwTyGU5iYePSA== X-UI-Out-Filterresults: notjunk:1;V01:K0:jZeIO7Twxyo=:3cbxrx0i9SuhUzkN4HSIMa 45WWAC6UuH9TN/lO/4UXuKFZetWw1LQKg75N4cCrfaQd2O94V8mfhXJebbBO+zdU+V2H2JrB9 SlO/eKwn8bq60/0+hJUuIxDE0oxRIxKEXHmw3h0AH67VLtpurzT5lEYqusJBGccZP2a9uUA3F Mo96pQCZ4mFyokj4/Z/NAEp/LdYpCNnuvTbuoE1c9DXBbaDLI7jgLZ934BR9sE2svrWmIsXhj 9ZQsMnLVfMtzqqAU/G5TuPpcOD3C2kASd/CJHOH/pfwx1IfDW9v7OqXSIfl/UykHkZTthzAiE SIwB62HP/NfYvso4/W2/Y51HC79/Ml5UNwW4W6RWSw380Va2K7Lp3KZG29sTH9hxGXxRe3xsc KNvinYPcWkXzcUjrWHFD05dQrXkqJnhnqffxJ4juvZy13X7OMb9VPYRKHwCZPVF9j3GF+XT7q 3f/arHhEsk9Dp4UuLNhD66lljU4g1jHD92Quoup/GhPmlukB+yU1JsdfhctHVPzuTKzNUdkfH 6acU8aPfsj6yj6A+fMZUAWsNLeuL6rcJDWFa6CMJEex+JftD6xKop2lUpdDA3Jf5Ma4lAjVgj lImAOWi/MdpGrsmBkYYCqfrUTOxN/8LONOkWv9UDKPc/iNFWaJoH+f10LU+envAsJzdHNIuqD BGvbZauhMul8Qwec6Fxbgxw6DBsyjaottyW1FIZFIKvpmdjmtanG5oqydMTpYYh343ub3utL/ h08nzM0ObQKZ5JEwT4f8X4XTOp72T7Fh9ZO495jbdvGZ4zXwaxi0oMV1O23u4ucjia6Q4AdjG kvhz+MixGcNKdvRNTcgS71cBeC56F4jG1Nkeuhos+teH5ugCXs= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-08-21 at 10:16 +0200, Peter Zijlstra wrote: > On Sat, Aug 19, 2017 at 08:10:49AM +0200, Mike Galbraith wrote: > > Greetings, > > > > While beating on cpu hotplug with the shiny new topology fixes > > backported, my memory poor 8 socket box fairly quickly leaked itself to > > death, 0c0e776a9b0f being the culprit.  With the below applied, box > > took a severe beating overnight without a whimper. > > > > I'm wondering (ergo rfc) if free_sched_groups() shouldn't be renamed to > > put_sched_groups() instead, with overlapping domains taking a group > > reference reference as well so they can put both sg/sgc rather than put > > one free the other.  Those places that want an explicit free can pass > > free to only explicitly free sg (or use two functions).  Minimalist > > approach works (minus signs, yay), but could perhaps use some "pretty". > > > > sched/topology: fix domain reconstruction memory leakage > > I was sitting on this one: > > https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=sched/core&id=c63d18dd6ea59eec5cba857835f788943ff9f0d5 The comment in the patch reads better to me like so: @@ -345,15 +346,12 @@ static void free_sched_groups(struct sch static void destroy_sched_domain(struct sched_domain *sd) { /* - * If its an overlapping domain it has private groups, iterate and - * nuke them all. + * A normal sched domain may have multiple group references, an + * overlapping domain, having private groups, only one. Iterate, + * dropping group/capacity references, freeing where none remain. */ - if (sd->flags & SD_OVERLAP) { - free_sched_groups(sd->groups, 1); - } else if (atomic_dec_and_test(&sd->groups->ref)) { - kfree(sd->groups->sgc); - kfree(sd->groups); - } + free_sched_groups(sd->groups, 1); + if (sd->shared && atomic_dec_and_test(&sd->shared->ref)) kfree(sd->shared); kfree(sd);