Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933316AbcKGSfA (ORCPT ); Mon, 7 Nov 2016 13:35:00 -0500 Received: from mail-ve1eur01on0094.outbound.protection.outlook.com ([104.47.1.94]:12018 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932846AbcKGSe5 (ORCPT ); Mon, 7 Nov 2016 13:34:57 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Subject: Re: [PATCH 4/7] mm: defer vmalloc from atomic context To: Joel Fernandes References: <1477149440-12478-1-git-send-email-hch@lst.de> <1477149440-12478-5-git-send-email-hch@lst.de> <25c117ae-6d06-9846-6a88-ae6221ad6bfe@virtuozzo.com> CC: Christoph Hellwig , Andrew Morton , Jisheng Zhang , Chris Wilson , John Dias , "open list:MEMORY MANAGEMENT" , , LKML , Andy Lutomirski From: Andrey Ryabinin Message-ID: Date: Mon, 7 Nov 2016 18:01:45 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: HE1PR0801CA0014.eurprd08.prod.outlook.com (10.167.184.24) To DB6PR0801MB2053.eurprd08.prod.outlook.com (10.168.86.22) X-MS-Office365-Filtering-Correlation-Id: fc87c00c-b113-4069-09c1-08d4071ef4b6 X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB2053;2:7J/GOaTbftBR5Y+SnYLOH92Yoj6MJorhCxY6WNwm+DGOhhCEjk3YzJX67mnBkjGfgJ03bF+8TuZNxqssMaZU7zEODffhY8DeyQDEmrQgAxqwqFQnjpNZJc8HccYYYf+PI+Zff72PPhvEtyubr3JgaG6RmDyd6KAVz2aALfTrAAUEniG3FPnA3rev/5jOuKhMJNfx8RZV3n4FPzThUCOftg==;3:VnLVtrXpAaPoLUbPkDkgpTQTHPkIQg/XI0SMlSESo3N74PZfovPiw/gTOo1zinPRczbteYQ+n9hKBDyP95CwOKRDZiKU6ttTOMmOnQHE0n6m4FC9rjB/eqm4PcISXkmnCvGWtp6Unp+xq64koJj/2Q== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0801MB2053; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB2053;25:s/68nB01xXS0HSz+hSAmKTQTyiyzJYQ2SiYanYzfi4WzeS62dHKJHRYtVJj4ezQDnj8Ih4NLn4pjj/cMa0ULjqh3YqFKnxjGkKS+xKGU1IB7AOd7awRPbHCwa5/EqUV8p9bMl7zfU0Hf6QVQt70XJg5ZVuG8L/PnXnh0BUr5AQgdIUkkPzsJt6nNTTC722zMCF/qNmG7hAD8Eqwyr9NK0MK9XovKgO4WYFcI9hE2aQndV7WylTBUtUd85pTgoidZzSQVMHtlPAdxSXMjliODJsR046WmcNUIJPNXC7Ij3QXKnFSUkC4UeG793J1pVSNcjoSaaXJiLC2mf2eYkxsch9gdbS1Y0d6tNfJFHUmrh8jzpxJtLZuMkzHnHI0ZmnYIBKIC569hB6dMlEKT+OgEY+H+WmJA9I9VFpgxfzXrD2+qs5J4lDoJwNuxLH+4uMQ7GOgDO055Wwo9n50yJ/yWPP0Us6AFDzCBmcKCBerlSba1UXPG0SxynuXvvgcNLb5e8vVrF3V4QASdjRzIdl+lS3lqafyNhnx700VD0zNX4zW6XlGQqSReClDCehlMELcesYktE2yhwSZLThw7o7YU+8Oi40yq8v7/rTvGEB9AYbD7J9acExOUMCQEXZDINTzqTnzpUgGvcYct4ZQulu7O5EGWoz2DL918PjG3cOqGci1wqetzaLeM4t9RwoWfBRjVoWTkrdYKJika9dyFC6HhCZ1sINNUFQM62HNzs5fJngg= X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB2053;31:h9WkHVRxstUx142gGKbw5B56FRDYcOIFYMup0VkRlP81XpUgYD0WQ1UA4Shjs2rBMWHr2Ij6poz5cwKk/LlrS2GlfdOksn+Ib82P+gETj8JzM8b3vxkpd3AOHiZrtm39MDUTrpmQaHsRhkZtuKrokoC9qrvhoh8S0baiTV7LJ98GJovhQUZerfj/WXNEFPmTDQLwrADSxi1vYV/rVAYq2Hv6n9EIgVib1Yd+AUSTKej4X61PcwOX+71EOALd6CVrrAuHX8fFYwHZTL7YoWGAbw==;20:GUuVluoju8NLL/3jJJhMWWTgvllzrhgIRdqmF3B48o/oTkjTWSemNyS6s1FQAQvV7NBwOc9DfcX2R1UatF92p5jOkz1yMV2PHzRNC8oIDGc25pOhRe1o5gZjfL0CV7yZfrdGjU/TmGEgx6qd2jvTr5lXSS5R06P6OvSgqCB+qUVVK9oD02hEqIWlwF4AULTFmn6R5YqYwiUGAkGrRN2uk+fGcMWkUigINCLz/9VH5A2981oQ1ZNDxKqw3Jd/yuZm X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6043046)(6042046);SRVR:DB6PR0801MB2053;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0801MB2053; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB2053;4:9dgUsIS4YuNMLBEeYzlHEEE8v758IHOJqmu0l2m0t18aQ4P3HbQifNg1DRJ9VZqgvPRChoWzCiVfLwRjVwE7orLIuVPqaEI3n7iEsAbBq5l7T5IHCXmgWSbdeIL4+2Z6mnnH/W08CaB6BgAoweV+UAo5oVlpVMAA68Pd7e53ILBkZBcYMjOQFSdaLXblAHk9T1u5cCVXRuZQCSxOZ7I4bu+F0FNfIX85Re6YfHzZIyN/cPJ+NyAhZRCnCumxdhPso4h1Um3yzRi9Op6U2izyVpRW5winr65/jGsiMlCbVUbLcdgH6SyHl7/v2UxLTjvvvQ1vwW8QndauBUlPUPyJYGVsky0HLBg/5CPH7DSifz2U6NcB18PmxW7oMPBvK/7d9dD4B5Bla92O3y3S2H71Hihpa6E3bHUsLvrOInHSy+a3HGjnLjTsROE74DX9eFCz X-Forefront-PRVS: 0119DC3B5E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(7916002)(189002)(199003)(377454003)(24454002)(76176999)(93886004)(101416001)(36756003)(81156014)(81166006)(6916009)(92566002)(6666003)(23676002)(7416002)(586003)(2950100002)(6116002)(4326007)(68736007)(3846002)(66066001)(86362001)(65956001)(64126003)(65806001)(110136003)(8676002)(47776003)(105586002)(50466002)(230700001)(305945005)(31696002)(2906002)(83506001)(189998001)(77096005)(42186005)(31686004)(5660300001)(19580405001)(19580395003)(97736004)(106356001)(7846002)(33646002)(4001350100001)(7736002)(65826007)(50986999)(54356999);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0801MB2053;H:[10.30.19.223];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQjZQUjA4MDFNQjIwNTM7MjM6TisxajdveStkZW0vcldDeDQ5SVhOL0dS?= =?utf-8?B?WEZvOTY1Tk1reEZtY2Q5RGRIQ3pwR01nRlBOTkwvYnZFbWxlSnNrajI5WUhN?= =?utf-8?B?QzY2dWRKWG5DWWo1TWFMZTVyVkhFNXRYMDB1UGs5TnAzM05ZVjdWeGxITzdT?= =?utf-8?B?TStoREVURkdiU1N1SFI4RG54T3lDV0FrUXU0ZjJWZUJFTzVOMnBVQzh4S3hX?= =?utf-8?B?UUJsQmVVWDBJdzJJRlk1NHcyU2gxSWtVM1h5c2JNNE1SZzZFZUtqRTE0aWtw?= =?utf-8?B?TGFMSk05a3RscE1sd2IrMnVvVTVSWE1TRzBBMlZ5UnljbnY1ZGNXSzVQcUNu?= =?utf-8?B?UVdmd1pPSi9RUjBkZzA2SHRyVDRQVUx1KzVodzZjOUxsN2w3MzZtaz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Q==;5:nOo07vrB4eMEQSJGMhb0mjvnE9CvGy1qlJzA6bqrQBKDnNsnZgEKUkOikcpZFzb9jez1+yGaveZN8ta27MYF5SKFbcF5bq7qFEG0nZwfOx0b6AzrSBX7VbeU7tP+16xYhgK7gpaimTone2Vutmy4MICcwYobNIb7n0GPM+ZSQ/E=;24:MDxLnVW+xZm6LsbCMj48p1RTB6e1MDZapLt61SaKqseLx1iwewMUNMJQkSjKUj+prnnjHMgSKcSUYnU3FNSUMMQiJ2LEllT++WYtKiVZftw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB2053;7:GSjw4SKWhSFmuhuofqF9/xSRsTmQo1aWgN+Ej3qyrfGyzRro71WsUn+ui0hGCdn7YDv5KhrQ9XT6ji4P7ap5W2cxvEowCxOdPw1rIdRCRSQtW1zp7cCDGNHZUFazr1Jy6JupIiYP+PLkxiJdkdF2Gj9ksEOEdSbeF3dbi7IBq+U98FWwnvV5JZp3oKnwZlzzMfYl7VAibGT4gAFWjMyv4SJuvDN92ONmY8naT3ZZrLxmq7fp3986tbAHd46RNZHWvELIzZLLGHil+DLxYZ8ZnkQs7aiwhCJe2VojcNiwhDonGWOWcOQXrmm5PoCDOdCrBhAKlfJTH3+Yca7OTKuTDc/OGExT4l2aZsFWSU+QoT0=;20:KWKeH2uR2wouPGKGQEB36BpD3c5xk4QNpp8kDQuo/u5OiQNHK9WWJuKy0avrmffuelD5gBTC18edqAU1/jPYPzztdNB2hcZawHfQORXpNWpqZMrvsb7iVHCwGeTSyqZPUPtxIxJgvoJV+cGbO6H7euVky68/pnSpvFh4PEHhPFs= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2016 15:01:28.6723 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2053 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1477 Lines: 45 On 11/05/2016 06:43 AM, Joel Fernandes wrote: > On Mon, Oct 24, 2016 at 8:44 AM, Andrey Ryabinin > wrote: >> >> >> On 10/22/2016 06:17 PM, Christoph Hellwig wrote: >>> We want to be able to use a sleeping lock for freeing vmap to keep >>> latency down. For this we need to use the deferred vfree mechanisms >>> no only from interrupt, but from any atomic context. >>> >>> Signed-off-by: Christoph Hellwig >>> --- >>> mm/vmalloc.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/mm/vmalloc.c b/mm/vmalloc.c >>> index a4e2cec..bcc1a64 100644 >>> --- a/mm/vmalloc.c >>> +++ b/mm/vmalloc.c >>> @@ -1509,7 +1509,7 @@ void vfree(const void *addr) >>> >>> if (!addr) >>> return; >>> - if (unlikely(in_interrupt())) { >>> + if (unlikely(in_atomic())) { >> >> in_atomic() cannot always detect atomic context, thus it shouldn't be used here. >> You can add something like vfree_in_atomic() and use it in atomic call sites. >> > > So because in_atomic doesn't work for !CONFIG_PREEMPT kernels, can we > always defer the work in these cases? > > So for non-preemptible kernels, we always defer: > > if (!IS_ENABLED(CONFIG_PREEMPT) || in_atomic()) { > // defer > } > > Is this fine? Or any other ideas? > What's wrong with my idea? We can add vfree_in_atomic() and use it to free vmapped stacks and for any other places where vfree() used 'in_atomict() && !in_interrupt()' context.