From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C117C433EF for ; Thu, 2 Sep 2021 23:57:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3DC2061057 for ; Thu, 2 Sep 2021 23:57:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3DC2061057 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 44CAB6B0071; Thu, 2 Sep 2021 19:57:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FB816B0072; Thu, 2 Sep 2021 19:57:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EBE86B0073; Thu, 2 Sep 2021 19:57:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id 20DD36B0071 for ; Thu, 2 Sep 2021 19:57:47 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D4AAD1844AD2E for ; Thu, 2 Sep 2021 23:57:46 +0000 (UTC) X-FDA: 78544298532.06.BB318B5 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by imf08.hostedemail.com (Postfix) with ESMTP id 7DFCC30000AB for ; Thu, 2 Sep 2021 23:57:46 +0000 (UTC) Received: by mail-ej1-f41.google.com with SMTP id i21so8284063ejd.2 for ; Thu, 02 Sep 2021 16:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dRoRhRHYyXTHQv8bSMxayqqRJxdPz8ler3X2VgmtUGk=; b=UCnuREBRlb3+hDmdkNMSSpSBdCxc69D46HwPkzU73Qvu/GoPPFdLepwOjne5RDR16z /tzbspfn3hOT9kEmg48gklALuDOBkxdwcMxZtwJLOIwYN6IwPeeKmO89pT0nN4bUWvQc 7A9bInuvT6GYwjL8AiGCJnHAdPYu7J6K5uf28= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dRoRhRHYyXTHQv8bSMxayqqRJxdPz8ler3X2VgmtUGk=; b=NYQoXZqwWhAzbGx+C09nEed9Kzrr4NYHRbzufQtPEB0+XS3TK/IONLZ0UxKAOilFSx 0ii4Ai8P8v78eln2ziU86G0GU+ZHwKBDrJuY2UKviOPTWhIoUSzqCzjOmFT8sEOdcVZV qlmF944L/Q2KKCSDujy3DSUJIP6u2en0zAP4F+fwigLTfQyEj7jNF/tpcpboO6lBln8F oPWEvz2RxJuOMUrVB65mlmyemGpnU9m6veRAW5MHlAAmRBjAv/HA5Wpzhc2pqa9gvILX 4MnPrxvAtx+j2kNEjOWD88n967PB/OW+SbYOMkVXfYj4NUQ7hE8pukqD9iRU/Ycc28wT QtZw== X-Gm-Message-State: AOAM532PL78xe3GRlupJDJrLwesLQsLDaUkYBfBp9JQL5ymUbYD1jgu+ ge1+CbhSMRqvVXcVu9Z07e6HJitsnkx9RiYuShE= X-Google-Smtp-Source: ABdhPJynyDJfbVbe1FrB7T3/+U1ZAgUT/W7bK/0wnFffj3v41f4Sefg2qU6mPULq08W20XHxxzvFhw== X-Received: by 2002:a17:906:8468:: with SMTP id hx8mr855507ejc.492.1630627064926; Thu, 02 Sep 2021 16:57:44 -0700 (PDT) Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com. [209.85.218.54]) by smtp.gmail.com with ESMTPSA id b8sm1974107edv.96.2021.09.02.16.57.44 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Sep 2021 16:57:44 -0700 (PDT) Received: by mail-ej1-f54.google.com with SMTP id mf2so8262624ejb.9 for ; Thu, 02 Sep 2021 16:57:44 -0700 (PDT) X-Received: by 2002:a05:6512:230b:: with SMTP id o11mr460496lfu.377.1630626723667; Thu, 02 Sep 2021 16:52:03 -0700 (PDT) MIME-Version: 1.0 References: <20210902144820.78957dff93d7bea620d55a89@linux-foundation.org> <20210902215152.ibWfL_bvd%akpm@linux-foundation.org> In-Reply-To: From: Linus Torvalds Date: Thu, 2 Sep 2021 16:51:47 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patch 036/212] mm, slab: make flush_slab() possible to call with irqs enabled To: Andrew Morton Cc: Sebastian Andrzej Siewior , Jesper Dangaard Brouer , Christoph Lameter , Mike Galbraith , Joonsoo Kim , Jann Horn , Linux-MM , Mel Gorman , mm-commits@vger.kernel.org, Pekka Enberg , David Rientjes , Thomas Gleixner , Vlastimil Babka Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 7DFCC30000AB Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=UCnuREBR; dmarc=none; spf=pass (imf08.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.218.41 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org X-Rspamd-Server: rspam01 X-Stat-Signature: w9g6q9jbtota1qspgtfu961p45zc3jzw X-HE-Tag: 1630627066-838436 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: [ Talking to myself while mulling this series over ... ] On Thu, Sep 2, 2021 at 4:34 PM Linus Torvalds wrote: > > Instead of having it lock/unlock halfway through the function (and > have magic "Oh, the caller already holds the lock, so don't lock" > semantics except with misleading names) I really think that function > should just have been split in two, and then the locked region can be > minimized in the caller only taking it for the first part. If there's some reason why it can't sanely be split into two (too many common variables or some odd control flow or whatever), at least the locking logic should be changed from if (lock) local_irq_save(flags); to something along the lines of if (!caller_already_locked) local_irq_save(flags); so that when you read that function on its own, it's clear that the lock is always held over that critical section - and the issue is that perhaps the lock was already taken by the caller. This ignores the whole misleading "lock" name when it isn't even yet a lock. Linus