From patchwork Fri Sep 30 09:01:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 9357843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 777F960757 for ; Fri, 30 Sep 2016 09:17:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66BDE29F39 for ; Fri, 30 Sep 2016 09:17:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AF4C29F3A; Fri, 30 Sep 2016 09:17:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77CA429F3B for ; Fri, 30 Sep 2016 09:17:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932303AbcI3JRd (ORCPT ); Fri, 30 Sep 2016 05:17:33 -0400 Received: from mail-db5eur01on0105.outbound.protection.outlook.com ([104.47.2.105]:62224 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752173AbcI3JRa (ORCPT ); Fri, 30 Sep 2016 05:17:30 -0400 X-Greylist: delayed 935 seconds by postgrey-1.27 at vger.kernel.org; Fri, 30 Sep 2016 05:17:29 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=paM+qIlMrlMjPhf/w1FaSIVB6K13FT4JRZ+9wUK2F04=; b=N3jlNz3jBm+phGajHIq9xtjnlSwXiEGubl35zF5dtIdKGC3/cMKu5B5i12GuzeXGAU5R5KTIryvV/6yQEyFJKH0v5Wm/D+zPI9rv7UjSJYaJ1UCLM8neqDe2U1zRuoN/Ls0cfVFS/8DK2JkQxOENzHoQIXwir4rwGQbpNKgPGBs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Received: from [10.30.19.223] (195.214.232.10) by DB6PR0802MB2550.eurprd08.prod.outlook.com (10.172.251.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Fri, 30 Sep 2016 09:01:52 +0000 Subject: Re: [PATCH] coredump: fix unfreezable coredumping task To: Alexander Viro , Tejun Heo , "Rafael J. Wysocki" , Pavel Machek , "Oleg Nesterov" References: <1475225434-3753-1-git-send-email-aryabinin@virtuozzo.com> CC: , , , From: Andrey Ryabinin Message-ID: Date: Fri, 30 Sep 2016 12:01:52 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1475225434-3753-1-git-send-email-aryabinin@virtuozzo.com> X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AM3PR03CA015.eurprd03.prod.outlook.com (10.141.191.143) To DB6PR0802MB2550.eurprd08.prod.outlook.com (10.172.251.148) X-MS-Office365-Filtering-Correlation-Id: 7578a889-4117-48e6-402d-08d3e9106c1c X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2550; 2:dL0+wZa6AQBjLU9h/En8r2Mu/LuSQ+ORp6tY2vhnk9GQoiVjzE1lSmW1z2XBoxSBnaMyYEr2aOm99w2IkXeUpQxMX8bQ0u21CNiMP+OO6bwNwT5xk4Y5uHS6A+Ou6eHhITaN3HlLoL7CZ6MJqEqAAeWFg2eZTprUlPcTBjsQk3dQTYqiojAM7glW6K6CihgC; 3:xAwTPUHgY0LaBS7F+qVCF4hVPS8oQXIn5weztgftpNBOfFOmayK5fqSXKPp/IKvDEMg/UacrVc7Mu/OmCI0M8JMeVrPZdpER3LQWNz/PO3UjpWtl4dD9xyKggruoToJf X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0802MB2550; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2550; 25:swF7YcHZApxRAMEPOSAk1r/SUcYws50b2E8sLda53RmMdU2RNQy8/EssIsCS1XVLvOXojF5OHlD5sncngTaVdHn8FNavaFmQy9AcvL/YQPfBE0D+7O7xNLA3gUYIsQGTvvBcBux6OLgUNOSZ9AeXWE2s1p8EXo1Wrqrd6ZTUkBlKwrAqLeahcl/dN3eBOE+n/6OVpZV5o7103J1k/qIjsT9efvbEFRdnrtyUr0SsJmSHqrHSerbzM2Q4VZNxua/ZqwsEPowsUvLcIZezoMDGPkIiDyKEeGCyOVOLOipE604ej1kJHeHuRT5nG7tRxfjdrIEn3C4z7UOoyiucbcFyQOlAW5eqhg+JpFKGUyxsoT1rRAXCWurrNuISK5BdeF0gk4NrAgeL7qISn855PjbCTiWX2l3Dz/UGk0nrosISsDdLJc/F5OKQKpOt4VYPZRTcgBJsGV5j5i+pPMUmTKXnRKvY3Yp6MH4vjj/iTvVAK4Psqz3/HM5ycQFzn0m55tBHh65ifMJfh1A42lcxh5laoz6yPWX/ZoMYsHVfddjTAsuSqrPWWTgh73bNaweQ3bf9bbkQnd1snuIdArTv+1R0z/L4SRGT4xqo04KCzjtPn8uhMNV96+8SaJJ+8arp/0jwOg9md1s+keFmQg0mUY5CRfnsjdzmW2PCDr/YGNcNG0Ybf2xw7OuqNS7SWkqPQDq44bqloP30HfOV1kGemCDEejN7mFIpm/fmwh0qHdx+sTI= X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2550; 31:MbCVnCEljHF7utauYil7gj3Q65NIzDMQdTC+GShlTWDY7Qr1u6sAHpM+3rLP57wLd8v1Ri2MQT8mRecwAnxYfKmqBi7cOgMmfJCNGvkZ7jUVxW7027CxSHc9irN1dV5COGMgQbQ09SVyDA/p4CoXIfbbcBkDgKHVvbn+PPFC9LkMdNlcDLSp/0/Z8y9t/OmMNkyinXKVWjGo7xrKhy426DpVJdNG7BrW16ZpHaiGBkw=; 4:v9QY2eQZwkgdumwYU6+uW3VXUeaNKCh1xkfMPG0qirY2h7eF0DTeeGsGTjrhwuBKgKmI3uQWVcLJjDDN3pnIt70DVbT4UI0+6x3wPUPSq/IlAEytuja6YwYc7gaUpMu5x3rb5AvAvvVX/u6PqrUD8qduQzwnkAN7aijpNaZiTogOjJLWc69lN+cHrLhfEin7XOZkNyVrYH+5HoDLEnud2PIAKSnvc/QB7PDmqPm9Bfs+uMhc2F7cV8K2uMG5aChg4E1bv9hbhsD0PAISLv2fL/3Gba6vmB8ZylZRo3ddYGbtCkmYEIYMT71WNkkhKUW03/fTyGJQ4oxxr1vcy1Yrtm68/FOfWOkUxb3A3qIhOjjkTZLROeszJyrxf7uVBuD8WKYvJqN0kK1ckGByXhVWmFRjzt7383cySeq6lBxT0EKTX5BgT98Afe9NapHV53ATOtPbYtV3Ib+KnzEhpkEY2Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6042046)(6043046); SRVR:DB6PR0802MB2550; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0802MB2550; X-Forefront-PRVS: 008184426E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6049001)(7916002)(189002)(199003)(377454003)(24454002)(586003)(54356999)(76176999)(50986999)(33646002)(105586002)(68736007)(42186005)(31686004)(4326007)(189998001)(66066001)(77096005)(65956001)(47776003)(5660300001)(4001350100001)(5001770100001)(97736004)(65806001)(106356001)(65826007)(3846002)(6116002)(2950100002)(81166006)(81156014)(8676002)(23746002)(50466002)(83506001)(305945005)(31696002)(575784001)(7736002)(19580405001)(92566002)(19580395003)(230700001)(64126003)(7846002)(36756003)(101416001)(86362001)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0802MB2550; H:[10.30.19.223]; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; DB6PR0802MB2550; 23:XFg/p7N1X3pj+UYKSxq+rM4zdVj39CSidOm?= =?Windows-1252?Q?dndDI5ETE+PEtalCZ4FGAklWmKSdhTrKcKkPeFQW4TudPk13DxI06yAT?= =?Windows-1252?Q?9YcW5txAv3EexpgJcS47xGJhNHcOlYQ2xLZqwkC1PDjyFBXC6tmjVTui?= =?Windows-1252?Q?Wh2mcFsCMW1vh0XgYxIZZp3wRAZbeiwa179Ii6BZFFjHxNUpWjo+5w4z?= =?Windows-1252?Q?X3QcWqkijiq0uhHtCf570TMXiM8hJk7avjwl2mFumMOoiAzQ1l4wP0q6?= =?Windows-1252?Q?Js6hoOja88kg64plza967KlKtMHti+xEGX99+a46CR6S19XOuTW9/3gM?= =?Windows-1252?Q?tboqa1/LHR7hC1YWMCQrYMRGDLyeoPpfO44ov5A2rgtkn8xpNHencJKX?= =?Windows-1252?Q?LMTDvDkeQ6cN17wTO6PdfTN/WZF+04Jg2EcStvA608xToG/wpZ/+3AVB?= =?Windows-1252?Q?AqnoEWJSc5dMXifhwdEASFHmZPmilFratEeU3Y47vIrtKPgOn32zqe4+?= =?Windows-1252?Q?9VNKpJz6bCWj6aa+/PJlDmwrfaokLJHfOFB2IhP5X4pXlHU1fSC6sA8M?= =?Windows-1252?Q?SHXDAJINBecVm7nY5VggG7/KPwszZU9WvcsuLwLZRoN016Ni1JFEnqXq?= =?Windows-1252?Q?kjFm9u9uFuBJsXh9dQ+XitUb6WuMt737RD8XnbE+2a9Df0gol6lDhSDO?= =?Windows-1252?Q?UnZ+WFGsPlUAp9sn7TC80FlUBnlbQlxI90jSPfBT87sspftKxKc1feRv?= =?Windows-1252?Q?wg6pDMnfpx+mCyH1TkTkB76VotvK3PjwcegUqgLJYxfJACsO03FmRbml?= =?Windows-1252?Q?CXDmLJsDHx4axlr/uP/upmVBktoMuPTUCb1ExpP9Jpv8KrXgtV7aO3b7?= =?Windows-1252?Q?zhiMJ3kW5n9lZ20yaFSY9ipWcsl5R4kB3BOl3jp6uqXFZdWVC5QG5RbN?= =?Windows-1252?Q?Wfsy75tcF63kM5WQWm9mqWF3KvGssj5fbU+hcVmNoHujNATSwER4Lisp?= =?Windows-1252?Q?CSnUwAUrigZGbF1APhAt/p0qTgYyvxVkVrLqEG3GyCJgXXYerfKAoeDV?= =?Windows-1252?Q?YX3qKTTBhW/7Fa8yFgJPl0fqag0qOQV0uAZOsBTAAREe3HAbVLFU70Qq?= =?Windows-1252?Q?lbMtn9QHDquPFcly4DIsO4Vi/Hvv0mRhez4XSspNnaQCADuEzKPmkPOQ?= =?Windows-1252?Q?jPj9XmhxufapywxaXJ9ktf87UalPB7UwPmLYAsb2ZwwfrNsVbQP3N3vo?= =?Windows-1252?Q?ffrevlgtvs8Lw7etE0/n/sbqCEOO5FkMDPOdgGUXz/v4PQikdn+TXBEj?= =?Windows-1252?Q?ZKLjOMBd7sj1reTPf96tdWZxbgoSdJTg79Guz386K9gABO183UDRuMrl?= =?Windows-1252?Q?ahiooY6w6qRl9hG93RlZynKKTz9I1AyOx42/s4Q63A0s/v5/tSI8hiky?= =?Windows-1252?Q?xZW4HQlVO4VOrqrGf1nMq?= X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2550; 6:RlLAFUSh0sfPQvODKax11s/1MnklMdtaAV2smTVF7wyfr5zLTKIsKqfv13tFHPm00Y4RtbVYYel5NpKyDb4RMpBSh22FQ+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+W4DJAs91Y= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2016 09:01:52.1482 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2550 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 09/30/2016 11:50 AM, Andrey Ryabinin wrote: > It could be not possible to freeze coredumping task when it waits > for 'core_state->startup' completion, because threads are frozen > in get_signal() before they got a chance to complete 'core_state->startup'. > > Use freezer_do_not_count() to tell freezer to ignore coredumping > task while it waits for core_state->startup completion. > > Signed-off-by: Andrey Ryabinin > Cc: stable@vger.kernel.org > --- > fs/coredump.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/coredump.c b/fs/coredump.c > index 281b768..eb9c92c 100644 > --- a/fs/coredump.c > +++ b/fs/coredump.c > @@ -1,6 +1,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -423,7 +424,9 @@ static int coredump_wait(int exit_code, struct core_state *core_state) > if (core_waiters > 0) { > struct core_thread *ptr; > > + freezer_do_not_count(); > wait_for_completion(&core_state->startup); > + freezer_count(); As alternative to this we could introduce and use wait_for_completion_freezable(): --- fs/coredump.c | 2 +- include/linux/completion.h | 1 + kernel/sched/completion.c | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/coredump.c b/fs/coredump.c index 281b768..c145233 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -423,7 +423,7 @@ static int coredump_wait(int exit_code, struct core_state *core_state) if (core_waiters > 0) { struct core_thread *ptr; - wait_for_completion(&core_state->startup); + wait_for_completion_freezable(&core_state->startup); /* * Wait for all the threads to become inactive, so that * all the thread context (extended register state, like diff --git a/include/linux/completion.h b/include/linux/completion.h index 5d5aaae..8c2626f 100644 --- a/include/linux/completion.h +++ b/include/linux/completion.h @@ -89,6 +89,7 @@ static inline void reinit_completion(struct completion *x) } extern void wait_for_completion(struct completion *); +extern void wait_for_completion_freezable(struct completion *); extern void wait_for_completion_io(struct completion *); extern int wait_for_completion_interruptible(struct completion *x); extern int wait_for_completion_killable(struct completion *x); diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c index 8d0f35d..0b9d1e3 100644 --- a/kernel/sched/completion.c +++ b/kernel/sched/completion.c @@ -11,6 +11,7 @@ * Waiting for completion is a typically sync point, but not an exclusion point. */ +#include #include #include @@ -123,6 +124,12 @@ void __sched wait_for_completion(struct completion *x) } EXPORT_SYMBOL(wait_for_completion); +void __sched wait_for_completion_freezable(struct completion *x) +{ + __wait_for_common(x, freezable_schedule_timeout, + MAX_SCHEDULE_TIMEOUT, TASK_UNINTERRUPTIBLE); +} + /** * wait_for_completion_timeout: - waits for completion of a task (w/timeout) * @x: holds the state of this particular completion