Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935364AbcLMUBc (ORCPT ); Tue, 13 Dec 2016 15:01:32 -0500 Received: from mail-db5eur01on0130.outbound.protection.outlook.com ([104.47.2.130]:59712 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933593AbcLMUB0 (ORCPT ); Tue, 13 Dec 2016 15:01:26 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Subject: Re: [PATCH] mm-add-vfree_atomic-fix To: Andy Lutomirski , Michal Hocko , Johannes Weiner References: <87lgvlzp34.fsf@yhuang-dev.intel.com> <1481553981-3856-1-git-send-email-aryabinin@virtuozzo.com> <20161213101254.GC10498@dhcp22.suse.cz> <20161213172441.GA22610@dhcp22.suse.cz> CC: Andrew Morton , Huang Ying , Stephen Rothwell , Christoph Hellwig , Joel Fernandes , "Jisheng Zhang" , Chris Wilson , "John Dias" , Thomas Gleixner , "H. Peter Anvin" , Ingo Molnar , "linux-kernel@vger.kernel.org" , LKP From: Andrey Ryabinin Message-ID: <3eb4bfa4-ff94-bb5f-095a-3d17d68bf411@virtuozzo.com> Date: Tue, 13 Dec 2016 22:21:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [84.47.128.244] X-ClientProxiedBy: DB6PR1001CA0021.EURPRD10.PROD.OUTLOOK.COM (10.171.79.31) To AM5PR0801MB2050.eurprd08.prod.outlook.com (10.168.158.140) X-MS-Office365-Filtering-Correlation-Id: b375c59f-b488-4e78-f086-08d4238e38fd X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:AM5PR0801MB2050; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0801MB2050;3:jhjXEuG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QKSMA6yg8eXA=;20:W78yiWqmtUU7uZm1sYl4Kh+gWWx9Ar+ysrNhZC8fwa8CrSbLArl0LkBl3oD7zZTddV5a0s0eKTXzUk2Hxt2KIvoJrMbPpW2EJIblwZDlnW3sDah7Xb5nCCs8rjAWLxsBMdcn0M6/inG49IHuQN4e4ecnaa0YKgeIVp9HoDbRZXeGtXYJRKHgflilgOZLRhBhmUc2so8eXFpN7o856CJ/lX1Ytu1xaVAIQ4BK0N7Gl0iY+0NgZSrrs1tkQXAWlgU6 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(42068640409301); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(20161123558021)(6072148);SRVR:AM5PR0801MB2050;BCL:0;PCL:0;RULEID:;SRVR:AM5PR0801MB2050; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0801MB2050;4:6gLpoEZU33uSW+3FMRjxyrInaBFOEYb9nwgPb1uhimpl3wBn0uz2ryZItUe0V2CKUfHTlhPTTNB50294KTk9fuhCtn0K8Ao4Ctp10n8f7LJasmSOJVHmOJ6GmVbde/trn2kx/GX5UEGK5fU2RE1ICJrqkvqJ8MxmSo6kQyNha0eEfNRaYh/oSyRihl3oVB8ljxbyfA198BIMTgarETEhNmss4Q5yrCa5g6relcCe9s7ghM/5qpk807ygntdn13qjM2VMMryWS1hHi7oQEg9BZfGR+efdaraOGuU8aE7jT/aPPJ18GeFrFTyZDHh9iQr+84waDJjkLmC0dzJWkGxl1/54XewtZ4DP/nzEIuu7huRM9U8Z0Oo/l5uf4F+1z/KeIjQvIK2oZbKy6Q3zRDgYhvupCkLE54kbgYPsZlWEzebaLSJ5pGzoFX74jQyvpBd/K9ReRtAs/4tiJ/ervGhDHL3N3FF4wlsFGcE3YX9fdlGsCVRkxiOWtxM57bf5n7GcnnTZr7HDuNicQrHGA0dqgTM79XKkeaeel0f3h7FxI+XvZqJc+nLl8BLpB6i9Mi6gS1ICJFv/zyUzwM3F3y0QTKJ8zjCyVVE6wePKuN+gzwhwOPfXmOoVhzPKZHfDrJYfxdwSozhBhvWI+MtLZ3kgXA== X-Forefront-PRVS: 01559F388D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(7916002)(39450400003)(377454003)(24454002)(199003)(52314003)(189002)(55674003)(86362001)(101416001)(230700001)(65826007)(105586002)(5660300001)(64126003)(2906002)(106356001)(50466002)(68736007)(76176999)(4001350100001)(50986999)(189998001)(5001770100001)(66066001)(54356999)(65806001)(97736004)(65956001)(36756003)(92566002)(93886004)(6116002)(7416002)(47776003)(230783001)(8676002)(4326007)(23676002)(3846002)(33646002)(2950100002)(305945005)(42186005)(6666003)(90366009)(31696002)(77096006)(81156014)(6486002)(38730400001)(229853002)(31686004)(7736002)(81166006)(83506001);DIR:OUT;SFP:1102;SCL:1;SRVR:AM5PR0801MB2050;H:[10.52.82.3];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTVQUjA4MDFNQjIwNTA7MjM6L2ZDNzVFMkpUSUFHZ0pWTHFrQkF4anhH?= =?utf-8?B?NUY4QWZvZGVtVW9ReCtQWkZWRThKWWcwNjY4UmNxY3FMQWY3STBWNkVVWXRH?= =?utf-8?B?bWRKUVVyc3lpVjZCemRHSXhoNjhOMzZyUFppOXU5YzJaa0FSWEQrMlhJTWpC?= =?utf-8?B?V3p2dlpuL1NXbnVuZ1dkajJoaU5GMlU1U3BTUS9RZVZzc0oxTmVaa1NML2di?= =?utf-8?B?QURLQkRMeG1lNDV5bjJER05qVnBWVG9xa0VHdHJVUkhwZ296NnI4YzduMXJE?= =?utf-8?B?dFhOeHY1MS9Fb29GajVjRXU3YnpXOXpzN281azVJNm1wWkFIQm8vNURuVlJZ?= =?utf-8?B?OXBSV2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aac8/hc82HFGbV++L0sG86jEhONoR+cQmuQp7Vo0YjTl27LjKncPm9wfwJNvd+P/bCwd4ldEpTfbxiBMICQPMyJs2aQA9GLg8Iy3G5UtK94r66hulh0urt8Ya7azE= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2016 19:28:29.1998 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB2050 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2200 Lines: 48 On 12/13/2016 09:15 PM, Andy Lutomirski wrote: >>> >>> But not quite acked by me. What happened to the vfree code that >>> causes vfree_deferred to be called in a preemptable context? That >>> sounds like a bug. >> >> Not sure I understand but the above stack points to a preemptible >> context (copy_process). My stack was different and it looks preemptible as well. >> free_thread_stack calls vfree_atomic unconditionally. So I am not sure >> why do you think this is a bug? >> >>> (This code doesn't exist in Linus' tree. What tree does this apply to.) >> >> Anyway, now that I am looking at Andrew's tree I can see [1] which >> doesn't have this_cpu_ptr. So I am not sure where this this_cpu_ptr came >> from. Maybe the previous version of the patch which has shown up in the >> linux-next and Andrew has picked up [2] in the meantime. /me confused >> >> [1] http://www.ozlabs.org/~akpm/mmotm/broken-out/mm-add-vfree_atomic.patch >> [2] http://lkml.kernel.org/r/1481553981-3856-1-git-send-email-aryabinin@virtuozzo.com > > The underlying issue seems to be that we have this shiny new function > vfree_atomic() which doesn't work in *non-atomic* context and that we It does work non-atomic context. It's fixed now. > have "kernel/fork: use vfree_atomic() to free thread stack" that calls > vfree_atomic() from non-atomic context. >From both context actually. Usually task stack is freed from atomic context: http://lkml.kernel.org/r/20161019111541.GQ29358@nuc-i3427.alporthouse.com http://lkml.kernel.org/r/CALCETrVqjejgpQVUdem8RK3uxdEgfOZy4cOJqJQjCLtBDnJfyQ@mail.gmail.com On rare occasions it can be freed from non-atomic context, e.g. error path in copy_process(). > I'm not sure what the motivation of the latter patch was, but ISTM we > should revert it. TBH I'm not quite sure what the purpose of > splitting vfree() and vfree_atomic() was, but I'm not seeing any > reason that the common case of freeing stacks from non-atomic context > should defer the free instead of just doing it right away. > > Andrey, Johannes, why should task stack freeing use vfree_atomic() in > the first place? Because vfree() now can sleep and task stack freeing usually done in atomic context.