Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2345901rwi; Fri, 21 Oct 2022 02:47:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5I3ARwOc/mrycMSrimP3GhKRHxcChn+v55rh/zgtrsnm6K0noJxUCfNT4kZ1pWTabX2oay X-Received: by 2002:a17:906:846e:b0:78d:ed3c:edfa with SMTP id hx14-20020a170906846e00b0078ded3cedfamr14642647ejc.515.1666345635661; Fri, 21 Oct 2022 02:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666345635; cv=none; d=google.com; s=arc-20160816; b=wW1nae89tJGdW4RCoWsKLKzkPkVQytiYDTb4TAW11PqHYK+eWIEM04PiTQFgLtGGS/ L5yAnCCmwBDLs0HdETEoFuEMevz/QsbxuLtnkYH5gzIzG1vj5CUO+piE4YRCyX6BX06B mKeQLy9ovzC9hWlGnUFH2TAaOHpz02DlCp3Rs3JIGQYmlzHozjknO0xuxB5R4i+e+gqq dKZk1jTxP6ED3Bgw/MjET6Zl+NtQ/LVtFqLfp4nzweJFIikOJC+eSDn0LamukhhqiuB6 W2qHk+gBuVHkrWSc2lI/3VFUBH5NHZ7YMcU65FKnBzvx2YQkY7MKlRw4zEcK1Z4248QM Ghkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=2XhPHMqDldgN1ze7MKDZr13yMbKq5wFeQ65+oI+zCJM=; b=kLjA9hHgildWBP8dD2lyvWrF6woGpH89v6EqWEJzhvlUvpcXuAEf3DqaA+gDLQ6YcQ eZ27VNrTwODTpzxhXs/aynsQKiFxA+xZRqsUU0SeGL16nx0ILhQvhA46OHlRjo5X5/kf AoahmPFy40jVHMInJYgChBeLcPfufv6oT1fvwA9migHRL9MUH3qIs8Jk1safqvlpTGj8 NUG2tifgTL5h353rkI2Su2a81LnPlM18NkOF+doAg6auIzJ4ZNT/cfeMypN7PJHs23sp 2T/+ju5DdjVh1Y3F+CySViFJFGBrggOHMBLlKGvYqd++fH9fjiNdBiTukJuOLYe/y2oY teSA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020a056402441500b004549b880c67si23775059eda.42.2022.10.21.02.46.49; Fri, 21 Oct 2022 02:47:15 -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; 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 S231193AbiJUJT0 (ORCPT + 99 others); Fri, 21 Oct 2022 05:19:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231371AbiJUJTS (ORCPT ); Fri, 21 Oct 2022 05:19:18 -0400 Received: from outbound-smtp22.blacknight.com (outbound-smtp22.blacknight.com [81.17.249.190]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6FE5211284 for ; Fri, 21 Oct 2022 02:19:14 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp22.blacknight.com (Postfix) with ESMTPS id 6E46CBAD1D for ; Fri, 21 Oct 2022 10:19:13 +0100 (IST) Received: (qmail 8314 invoked from network); 21 Oct 2022 09:19:13 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 21 Oct 2022 09:19:13 -0000 Date: Fri, 21 Oct 2022 10:19:11 +0100 From: Mel Gorman To: Yang Shi Cc: agk@redhat.com, snitzer@kernel.org, dm-devel@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] mm: mempool: introduce page bulk allocator Message-ID: <20221021091911.ak3a7a3wr3qcbe3b@techsingularity.net> References: <20221005180341.1738796-1-shy828301@gmail.com> <20221005180341.1738796-3-shy828301@gmail.com> <20221013123830.opbulq4qad56kuev@techsingularity.net> <20221017094132.vnanndrwa2yn7qcw@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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 On Tue, Oct 18, 2022 at 11:01:31AM -0700, Yang Shi wrote: > > > Yeah, I didn't think of a better way to pass the pages to dm-crypt. > > > > > > > > > > > How about this > > > > > > > > 1. Add a callback to __alloc_pages_bulk() that takes a page as a > > > > parameter like bulk_add_page() or whatever. > > > > > > > > 2. For page_list == NULL && page_array == NULL, the callback is used > > > > > > > > 3. Add alloc_pages_bulk_cb() that passes in the name of a callback > > > > function > > > > > > > > 4. In the dm-crypt case, use the callback to pass the page to bio_add_page > > > > for the new page allocated. > > > > > > Thank you so much for the suggestion. But I have a hard time > > > understanding how these work together. Do you mean call bio_add_page() > > > in the callback? But bio_add_page() needs other parameters. Or I > > > misunderstood you? > > > > > > > I expected dm-crypt to define the callback. Using bio_add_page > > directly would not work as the bulk allocator has no idea what to pass > > bio_add_page. dm-crypt would likely need to create both a callback and an > > opaque data structure passed as (void *) to track "clone" and "len" > > I see. Yeah, we have to pass the "clone" and "len" to the callback via > pool_data. It should not be hard since dm-crypt already uses > crypt_config to maintain a counter for allocated pages, we should just > need to pass the struct to the callback as a parameter. > > But I'm wondering whether this is worth it or not? Will it make the > code harder to follow? > A little because a callback is involved but it's not the only place in the kernel where a callback is used like this and a comment should suffice. It should be faster than list manipulation if nothing else. Mostly, I'm wary of adding the first user of the list interface for the bulk allocator that does not even want a list. If there isn't a user of the list interface that *requires* it, the support will simply be deleted as dead code. -- Mel Gorman SUSE Labs