From patchwork Fri Jan 27 18:46:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rik van Riel X-Patchwork-Id: 4650 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp989639wrn; Fri, 27 Jan 2023 10:50:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXvc1vedHeV7RWg2fDRCRjhsuJcxfk23fZHrKlbXdNovEG7appIPakvaQbYQTqGAQpqHbMsJ X-Received: by 2002:a17:907:8d18:b0:7c0:d6b6:1ee9 with SMTP id tc24-20020a1709078d1800b007c0d6b61ee9mr47570038ejc.11.1674845405105; Fri, 27 Jan 2023 10:50:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674845405; cv=none; d=google.com; s=arc-20160816; b=eq2JKhlVAb6TJbhn8SOEyWp8iW9CGmvYthHDH9z9PjfUmbmVzJXSFAlyxnSICirQvz EXdzc7RwOpVtE0mjCGDAbRcakSaUDEd2G89tIvn4NQeM2hzzlT0/Qot071uoGHH2cvzG 1y0j8z7JUSJFaaM5jwBvEQpD9ygX2Vm3SwcLaxcHrj4IMwUhCfhwYh3XHwBPFUU32l2i L7ShMPvfhE0d6AJHab6GN0zyA0cGVYU99rolbhIQdWqe8HlrqTP2Y3KMcB/I3WDTB8p6 TbRhWfMvsYGwM6s8NF4Y7pXv2Q5OpAlkWRyyG3Z8lHLLaD7c5hsupr7fWcFI2qo+t3Xf +AHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=o6nOtc1Or0AMaRqn4+2K8ZsNndUgYfJCcnUio9pk/SQ=; b=k+iNsN2ZfyIa6aASe3sBRySDs2m5UyXzw5zBGK9D9wyFN4Im49Y1OWArC/hBKOafh2 ZIBPrWyi9TvtaotyZoE0e0/IUIxmysueQh/cOlV1p6Ud329MJ2hakydFwaa0ELVegRF7 7wsTkFKnx+yN9TdfWS8IkLDlDiP5+wgTqjxtxPod7h/U/ThTRFiBT5aZS3lYHhI9GaOH C98NuRRVy1pZuUsL6AXOhlJ/aN7oVJmUQNKZk4m9QSm70u8uhQPrnGAj3Z8cH6k3PHeO 0WIjQ8wrfYvQfRlf1TLXP51kGm/br1stxdVZrz6rJ2vNxYP/yNs6dJsIFFT7bicqBmqM YQ/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id az24-20020a170907905800b0087194db3565si4955742ejc.551.2023.01.27.10.49.41; Fri, 27 Jan 2023 10:50:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235125AbjA0SrX (ORCPT + 99 others); Fri, 27 Jan 2023 13:47:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235088AbjA0SrO (ORCPT ); Fri, 27 Jan 2023 13:47:14 -0500 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41BBD757BE; Fri, 27 Jan 2023 10:47:07 -0800 (PST) Received: from imladris.home.surriel.com ([10.0.13.28] helo=imladris.surriel.com) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1pLTkW-0008Mm-0x; Fri, 27 Jan 2023 13:46:56 -0500 From: Rik van Riel To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, kernel-team@meta.com, linux-fsdevel@vger.kernel.org, gscrivan@redhat.com Subject: [PATCH v3 0/2] ipc,namespace: fix free vs allocation race Date: Fri, 27 Jan 2023 13:46:49 -0500 Message-Id: <20230127184651.3681682-1-riel@surriel.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Sender: riel@shelob.surriel.com X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756202695098619158?= X-GMAIL-MSGID: =?utf-8?q?1756202695098619158?= The IPC namespace code frees ipc_namespace structures asynchronously, via a work queue item. This results in ipc_namespace structures being freed very slowly, and the allocation path getting false failures since the to-be-freed ipc_namespace structures have not been freed yet. Fix that by having the allocator wait when there are ipc_namespace structures pending to be freed. Also speed up the freeing of ipc_namespace structures. We had some discussions about this last year, and ended up trying out various "nicer" ideas that did not work, so I went back to the original, with Al Viro's suggestion for a helper function: https://lore.kernel.org/all/Yg8StKzTWh+7FLuA@zeniv-ca.linux.org.uk/ This series fixes both the false allocation failures, and the slow freeing of ipc_namespace structures. v3: remove mq_put_mnt (thank you Giuseppe) v2: a few more fs/namespace.c cleanups suggested by Al Viro (thank you!) Tested-by: Giuseppe Scrivano