Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932119AbcLLPCA (ORCPT ); Mon, 12 Dec 2016 10:02:00 -0500 Received: from mail-db5eur01on0097.outbound.protection.outlook.com ([104.47.2.97]:17158 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753217AbcLLPB4 (ORCPT ); Mon, 12 Dec 2016 10:01:56 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; From: Andrey Ryabinin To: Andrew Morton CC: , Stephen Rothwell , Christoph Hellwig , Joel Fernandes , Jisheng Zhang , Chris Wilson , John Dias , Thomas Gleixner , "H. Peter Anvin" , Ingo Molnar , , , Andrey Ryabinin Subject: [PATCH] mm-add-vfree_atomic-fix Date: Mon, 12 Dec 2016 17:46:21 +0300 Message-ID: <1481553981-3856-1-git-send-email-aryabinin@virtuozzo.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <87lgvlzp34.fsf@yhuang-dev.intel.com> References: <87lgvlzp34.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: HE1PR02CA0053.eurprd02.prod.outlook.com (10.163.170.21) To DB6PR0801MB2056.eurprd08.prod.outlook.com (10.168.86.137) X-MS-Office365-Filtering-Correlation-Id: 225ff559-04f7-4804-eda0-08d4229d985a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DB6PR0801MB2056; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB2056;3:j1EWvmeVqlXVyIfzZOxVoB8Iz63eCELCalQSpSqA+9tCxgImHXThw8A99M7dbzgrJOGcwUs4aKjzPni3RRWSgSIeKKkjQnu+9nCu0vqxisPAd2dXkBD9boFQsAujkvT6b9CY6b66zk9j4ru6G6O/AOpTmOsUOHgrsxRuJktiTeKxJefstMmP/kQk1xqYk1z59Ka2Vkh7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aaae5eI1i07EBfOadQwMWY7xs38kkCI/YDPZPpswqwk8A37Fc48R9gs6k8b175lSR0Dt//CT04CH1J5EPmIu6RRmi6kyDJ9MOHjFNoGy2+a0KZhoKc0rLrrT25rh3A/OWF2vw9EAu2fBWm5TXA99SfmEr9gWUrPuZgUvojsuRK5aH;20:Mryr4e/n3Wu2smBoAejGdAIAmhGImwJ5KiofPkaeoCeAA5VprTfGSKxiRKEqtRgh/W6FGd8J5z+YmasN8MyCPXOB6BuWGtdJE3QWpZGwNj2DmmGNctqH7b44Hj8I9uSkykmgqlGPBwPfc2QSh0GbRsLZf/osI2oAZIRG4pIjgKKIptlWXjGln9YhuyHu/WGfh9wSeMeRoY9nYuz1z60Lb8GWqG02iVk88U+erNx34cVmi33gncUw8IElfZKGoUa7 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(6072148);SRVR:DB6PR0801MB2056;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0801MB2056; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB2056;4:QGLepjZOsrdokdG+1jCVZ3FgSeXmqn2hqj3JBadKZlvY13hWCBGAuNRMUw/Zdqgz+grP7J/dEEuO+MZkk6bMFrv0wq9fChdWSAwfpCaLjaVnsy5PeK66bhO8/sFFFUN13NGXb3wgDoLkOx+uIuzW6KwrQXogBhtmKcbejG2KofG5HsrvJyi4lUETmpOpKVxfb+tf1RAqwWLaCXJtfGExuIET2APysbsNOyxdv0eqQjlYrZmXLeBZMNkyMGnOh16Syx6exPeSIbtqTuVs+aS9MKJuT4akDaYGUrp9lc/bTGHAD7CO33qEFuKnOXjHp1q0denPBnsrKidg+AwwXOSpIBWjSLSm4r7QUhQqz9KmFXlBdeezriB68IRoudQVfqmQAQpgrQRSXhhD3Rp4jXVlBT5mrsSi7kFpDI1Noo5jjxLPaj52hr9jFGOex8fueoW859gVsRyD9rXMqMXgcND/eICe0RaDt1jvMg8zgfkzLw2PkTMZgo+3yNVtDHUDdQrRwlOKNUEb/UJGEYanP8Rm6C4FrtxhU0HVfqdgY8ZfyECmehAvl5KmjJsPnff1BDAjDx304MN+wL0rxoxmGleZq040zczNuFEf0o07++dfwraweqI0u49MQ0Rop2coUUVb X-Forefront-PRVS: 0154C61618 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6069001)(6009001)(7916002)(39450400003)(199003)(189002)(4326007)(50226002)(2906002)(2950100002)(86362001)(8676002)(97736004)(50986999)(101416001)(81166006)(81156014)(189998001)(107886002)(6916009)(76176999)(6506006)(6666003)(6486002)(230783001)(68736007)(36756003)(7736002)(6512006)(66066001)(92566002)(5660300001)(305945005)(69596002)(38730400001)(33646002)(76506005)(105586002)(47776003)(42186005)(106356001)(110136003)(7416002)(53416004)(50466002)(4001430100002)(48376002)(6116002)(3846002)(5003940100001);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0801MB2056;H:localhost.sw.ru;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DB6PR0801MB2056;23:EwZK+mu7MNfEhf1OYGZ/X5ZpKcrZafGuAZn4pgo?= =?us-ascii?Q?98lSMPSHVNh1qqKlwghwjzpuGVRQQleS9MbyqHJu8J/xkVzFr43HujrbOAi7?= =?us-ascii?Q?LQR9d10yBcvd7JDvR8kkq5LOs3Mmj+ZR9FHatpRgYzBgtAZIMhxEePzp+PO1?= =?us-ascii?Q?m2kotxThoQOb9/t7IJVhA7aGAuaRZPmXB59dVY5LcyBC+9eWX2WY708GmSnD?= =?us-ascii?Q?flHJ2P5KriLXeZ6BX5qVypHi53ziH6dzYHDusgMHi0j0Db4Q30cRUgM5I48R?= =?us-ascii?Q?MDp0Gj4IXHC3dka920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?us-ascii?Q?U44LaaAWts8y5PzgbaCqfgmPc50kEW9RwCtVeuamxSGAb2dVUSpicHKcIHA?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB2056;6:4QkVH4F6XKpPmiDd5dFvAQjRlcao6Q2+Qb7ARxc6uCOAtWcm5O2dd+ZZWQl39X2qBHOl2qeGZZHD6eBH1HXtL/kOyRzMaXHI8ntJsdi9QCz4IN6jrK3OagoLBozkLhnzZovG0uUZolzJxMKnvAapwv5MBR33wsW2kjEHcjedMJACkVdJQ5yybptN0RHGDDODaK+MNrtjzTXUHVOp/xASvOqnFFY45JCRpkijRdvkSblW3FOtrv+57Kef0qjok/WiETZ07hVYgDbyQTiDsDzFiNTiqPegAqDzYNPLaUT9qRLAO3t490zo8rgtv/21BcjfesY0TGT0vmusQfcsAFE/IUlSNgWWHKjuytKJDcZy+Nsb1M6UVnaMLka5dljLow5n1dsIKQafVxafbO5JOQWhZoJWEJMSv3NHAG+KbPVpg7Y=;5:ml17DSCNXgoK9xAr4mBqrcEScFt+Pmm5vqutzRD63O+YwEd8CRiNqYiMrcELQO9zh4jPpocdbCEV4tGW1hw9NaO3ilbe3humQlNgmr4NHmIbQRWttVlP8klFqqdzuR0hN29oC6r8xXCNxRMulvezJHRi1jmWFWSBnWEWmsz3qHY=;24:LqcpYkW3haZ0Tqmtldr4z1GEQ99rf+FVk7WEoVZNNZiP2I4/sp6L3Q+w/+E9AOOd84p5awc8QD0Qc1Dg11ha3KXt7n/oIWvH+FanRnMCJQc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB2056;7:0BE/6Y4P9Lq7cTM7d9qhtsnvI0dK36CJ7htCOrFM8bJofep0vNnwRQgAWRKIv2To5QbRMqdunYqiXRYBKhHglLDaGgU1QKjbEFrqBoE4NzaeVYSvcCBTuLeBPojckb9KrA9udLKTAeh8lkyBMaUEHPtX1hgnDnsIh2mxUOo9E2JWMxpGnpJMwDSHIRSZm5agXYF3YPetYJ7jCrCeaDL6ODS0Ip71teEm5VlZu8lIfuBCMLqFDIOc4UeYxVMoAUpQ/dWK+lZuUyVwmNqf5N2b7cvUHqzeQYEocnspxve/X0A8NIzjnHA4S0WEP/sGfWFSljiKlGiLDajjDFtik0NKdOG2iN4TXxzOT9BN9nAkAWpwNmv/NHIOQKEAyElO8YJj7LXzYBeP5c9qQ6m1qgQGkGbWNM24ziECbqAgkfLHnu8RFqDweCfMemuZMrUvDVAEbKcoZUkUx748rVUWexhunw==;20:ZgportxadHVDa+bP9IGzNbKs+MSnOnLdcS1m0YjcSvrP66nGRzgBEZSKbXRBf4mov5hmz+ZY5sPOUVkANh/Vxf+Jca0l9bfxDM+vP7zCPsoaFkdaMby9RBRVHzP22OqB3G5dHThLaKy5sapzzHRhbtiVs1Ou49YCvZaNYl3gCTs= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2016 14:46:00.6911 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2056 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2390 Lines: 55 DEBUG_PREEMPT complains about using this_cpu_ptr() in preemptible: BUG: using smp_processor_id() in preemptible [00000000] code: iperf-300s-cs-l/277 caller is debug_smp_processor_id+0x17/0x19 CPU: 1 PID: 277 Comm: iperf-300s-cs-l Not tainted 4.9.0-rc8-00140-gcc639db #2 ffffc900003f3cf0 ffffffff8123ae6f 0000000000000001 ffffffff818181da ffffc900003f3d20 ffffffff81252f41 0000000000012de0 00000000fffffdff ffff880009328f40 ffff88000592c400 ffffc900003f3d30 ffffffff81252f6a Call Trace: [] dump_stack+0x9a/0xd0 [] check_preemption_disabled+0xdd/0xef [] debug_smp_processor_id+0x17/0x19 [] __vfree_deferred+0x16/0x4c [] vfree_atomic+0x22/0x24 [] free_thread_stack+0xc2/0x106 [] put_task_stack+0x4c/0x62 [] copy_process+0x7e0/0x16e8 [] _do_fork+0xbb/0x2d3 [] ? __do_page_fault+0x2e1/0x384 [] ? trace_hardirqs_off_caller+0x12/0x24 [] SyS_clone+0x19/0x1b [] do_syscall_64+0x143/0x173 [] entry_SYSCALL64_slow_path+0x25/0x25 Use raw_cpu_ptr() instead of this_cpu_ptr() to hide this warning. It's fine because llist_add() implementation is lock-less, so it works even if we adding to the list of some other cpu. schedule_work() is also preempt-safe. Reported-by: kernel test robot Signed-off-by: Andrey Ryabinin --- mm/vmalloc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 43f0608..d8813963 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1498,7 +1498,14 @@ static void __vunmap(const void *addr, int deallocate_pages) static inline void __vfree_deferred(const void *addr) { - struct vfree_deferred *p = this_cpu_ptr(&vfree_deferred); + /* + * Use raw_cpu_ptr() because this can be called from preemptible + * context. Preemption is absolutely fine here, because llist_add() + * implementation is lockless, so it works even if we adding to list + * of the other cpu. + * schedule_work() should be fine with this too. + */ + struct vfree_deferred *p = raw_cpu_ptr(&vfree_deferred); if (llist_add((struct llist_node *)addr, &p->list)) schedule_work(&p->wq); -- 2.7.3