Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19188rwd; Tue, 30 May 2023 15:27:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EALqaeolYmEC0Shif3PuMtLjAGntvgRLzEB0IwgNc+HD5q1hZXVdLBsmSJCyEBm+oYzlT X-Received: by 2002:a17:902:ba8d:b0:1b0:577c:2cb with SMTP id k13-20020a170902ba8d00b001b0577c02cbmr3521271pls.25.1685485670840; Tue, 30 May 2023 15:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685485670; cv=none; d=google.com; s=arc-20160816; b=Qku7pYWEnMNdFtc9nbaYBSE9Po/QNd2uMFmKMawrPkcKZXsw5kkLNHwRT4u5t9mR77 mnfDWrYWCi1A2VpdHOiCbrVUaMI+oy4NAcX82Cg/8oG6J3EIqHlsKf6GFD89mYN0hLJV aDq7MJFjW6Yd7xQP66AnIgrKonnazDabaxmd4VuqsQImn79eopND9JEbMMPPDhIKFJ4l G2C8W16tajQvv4XA6vzYF+ThIAdpQnLu/5m88AAYFVyFvBNCv9Jaxr8vbFYwbjAw9mji MvufszSvAR/jm3DEvqB1MRwMPDwGQKlljFlHHNR6ASYaQKTQNffK1QH1O1gOzojS/0oo eGdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=o5DUvOnBbNjICLS8rqmJBzZV+nxJEkq4dfwQCNKJREU=; b=Ohi9emlt4xzkVmdx5moMGBeYsFFOU0t3Id8Jc0hhPcLc1ALXh0CeHSCXM7Sq9MulKe dTkPKJbFWZisaJLzTjEg8Dwz/JhNZiM+SvaRDhNPQBnA4KkLzpUbqi+P+wVlWaNs+SVt nhCGkjBcOTBE74XynT7I+TsEHPPFeeRk3tyORhOiW/U1qDHlbd+3nifcAvEfVFxeOnUE hcIUd15GvJVPJjTOocuaYjmci4YqsWpmS0KgZ0XJtIas+4+7V59jRo/T+rI6IGun2Bsw J+thhGE2oP4qu7EhbOgaT8Q7rz2NGD6XdhOZJ7ctWc5qzQFUXuC6gHnKAiGTKJ1XjlYR pjAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=UfeedNde; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f13-20020a170902ce8d00b001ae5e5c275asi7463047plg.364.2023.05.30.15.27.37; Tue, 30 May 2023 15:27:50 -0700 (PDT) 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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=UfeedNde; 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 S233691AbjE3WSC (ORCPT + 99 others); Tue, 30 May 2023 18:18:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233689AbjE3WR7 (ORCPT ); Tue, 30 May 2023 18:17:59 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 821CC126 for ; Tue, 30 May 2023 15:17:51 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-51492ae66a4so5400069a12.1 for ; Tue, 30 May 2023 15:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1685485070; x=1688077070; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=o5DUvOnBbNjICLS8rqmJBzZV+nxJEkq4dfwQCNKJREU=; b=UfeedNdeoLrVx4A/HM6fQhmzFaQnWlmLcx/7ycZv+F9FLOUPPvvWAyy+mvDqCyIbjW 1V6GG20aa8VsCIlIyny1+5Cxnk2S+E34VwhES2uMpNt9uBP2s3uUyQVLwZ9nuz3B1PYQ NuMigSOVoEz9S3s7MLyMFb0Sce2wPUmkaBLuI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685485070; x=1688077070; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o5DUvOnBbNjICLS8rqmJBzZV+nxJEkq4dfwQCNKJREU=; b=KjQA8tMpXRnYqk/ZGIy/G6rAehAjktNVZT802B2Zp1HLaphMucmqt7r4FhnYDo//Ak J1kIycyueghDrU1S8X3mosN3n8eb53+4FRX95SrvlT45Qmla/hkZoNeFAS90z+vLXTqS 9qCPN2KB5I/t3Nf4EzeFZmjaPj5EOdyHSiNvu92vZ4b5OFMK/xyYKgD0dUah+cPKVOO1 LSPax9hwSGW03VbC3Biq4iT/dv3rWSJU9MOmQQaKFpWARL1e6uh/XGdu2BuF8IfWlbzS hHlOGe7CntmBA+H6/xeteG1XJ4hwN9fxFbfejtjZ0KCtJrSct7Y+2hGlAVXJyvyqVT7k ZIQQ== X-Gm-Message-State: AC+VfDxmfbkhZGiJ38slUZL1z3dLNrGTZrSgpirBNRYSi0lrZ8iilk17 Z1Xyue7K7ivWsOW2Tbx635ifVMuQ0O/O2ImAOGqCp/va X-Received: by 2002:a17:907:8a28:b0:94d:69e0:6098 with SMTP id sc40-20020a1709078a2800b0094d69e06098mr3652700ejc.45.1685485069886; Tue, 30 May 2023 15:17:49 -0700 (PDT) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com. [209.85.221.52]) by smtp.gmail.com with ESMTPSA id a9-20020a170906244900b0096629607bb2sm7926229ejb.98.2023.05.30.15.17.49 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 May 2023 15:17:49 -0700 (PDT) Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-30959c0dfd6so5205527f8f.3 for ; Tue, 30 May 2023 15:17:49 -0700 (PDT) X-Received: by 2002:a17:906:7945:b0:965:6d21:48bc with SMTP id l5-20020a170906794500b009656d2148bcmr3770717ejo.75.1685485048586; Tue, 30 May 2023 15:17:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Tue, 30 May 2023 18:17:11 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] module: add support to avoid duplicates early on load To: Luis Chamberlain Cc: Lucas De Marchi , Johan Hovold , Petr Pavlu , gregkh@linuxfoundation.org, rafael@kernel.org, song@kernel.org, lucas.de.marchi@gmail.com, christophe.leroy@csgroup.eu, peterz@infradead.org, rppt@kernel.org, dave@stgolabs.net, willy@infradead.org, vbabka@suse.cz, mhocko@suse.com, dave.hansen@linux.intel.com, colin.i.king@gmail.com, jim.cromie@gmail.com, catalin.marinas@arm.com, jbaron@akamai.com, rick.p.edgecombe@intel.com, yujie.liu@intel.com, david@redhat.com, tglx@linutronix.de, hch@lst.de, patches@lists.linux.dev, linux-modules@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pmladek@suse.com, prarit@redhat.com, lennart@poettering.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 On Tue, May 30, 2023 at 3:41=E2=80=AFPM Luis Chamberlain wrote: > > OK thanks! So just to confirm, it seems fine to return the same error > code if duplicates wait, or do you prefer for some reason for there to > be an exception and return -EEXIST if the module did succeed in the > duplicate case? I think either should be fine, since either was possible before. By definition, these are module loads being done in parallel, and so any of them "could" have been the first, and returned success before. And by extension, any of them could have been not first, and returned -EEXIST if somebody else loaded the same module first. So that "somebody else did a load" code: if (idempotent(&idem, file_inode(f))) { wait_for_completion(&idem.complete); return idem.ret; } could certainly have made the return value be something like return idem.ret ? : -EEXIST; instead of that "return idem.ret". But it does seem simpler - and more in line with the conceptual "loading the same module is an idempotent operation" of the patch - to just always return the success value to all of them. After all, they all did in some sense succeed to get that module loaded, even if it was a communal effort, and some threads did more than others... As mentioned, I don't think it can matter either way, since any of the callers might as well have been the successful one, and they would basically have to act the same way regardless (ie "somebody else succeeded" and "you succeeded" are basically equivalent return values). If the module was a prerequisite for another module being loaded, either -EEXIST or 0 _is_ a success case. Linus