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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84982C4332F for ; Mon, 7 Nov 2022 21:36:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26F466B0072; Mon, 7 Nov 2022 16:36:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 21F866B0073; Mon, 7 Nov 2022 16:36:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E7166B0075; Mon, 7 Nov 2022 16:36:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 019786B0072 for ; Mon, 7 Nov 2022 16:36:29 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CDE9C4046E for ; Mon, 7 Nov 2022 21:36:29 +0000 (UTC) X-FDA: 80107955298.22.4899F05 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf01.hostedemail.com (Postfix) with ESMTP id B5A8040013 for ; Mon, 7 Nov 2022 21:36:27 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id s196so11644429pgs.3 for ; Mon, 07 Nov 2022 13:36:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0tQ7MqopprIdRhb/IgvKRUjGQBe2LKpMrEFgj2d9jZg=; b=M1k2UTfxuajNc/oXu0LY2P83Vd6nzF4vsNIzUWoBnmefSmqUYpjNgicnLsxLPpisLb jPkY9vCm6EFryy8KQ1OzKez3Trva3tiqeOp197xzXqo94hWFlu9UwwpjxJwv/WMSC/+G Qvh2gU2cvXsntxroGga6/4cJal+65h+gZdq697jW8ScV1cljBAMaAkJ2N94z8RxfLQ14 NAtLJwbhGJ4TKHuz4zUc7huMFbiah9SGAK5A2rhAOrEqP5GCQH8OFP0R7Dfnyf3zBcaX GZIt6Wt64YchXsxJ/6ghFniaO/c+49GjJH3elxH4mHdREZZGQNDDtjbwizo7OdECLKJP HQrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0tQ7MqopprIdRhb/IgvKRUjGQBe2LKpMrEFgj2d9jZg=; b=LobJ1Wm1A5rQYPgjYvWzadV5bcelMGRUS+AlanCM/eLyVLK60zVKjMjhmNAJZaYEOo ylhUL/yEe3PSb4GinQqPzP/A2Va4mKseLdTf6dixTi2gaf46al8oDAEEfX0q6GrUJnrn ap7kZqrwDRNmbgHjUglnwGe/9dww07y9KLg3SCi0LQUg6UEMvDiy9X3URpVRGXmXCgq+ 82kqLXWRbcY95RY/jkITxm/HHWcFfs6yKSkdN+zOvj/BmGDbShkEtG+rEZFaYhtjhaeT EvDj5CAQi+/bhqAr0RrkxwHHkKA1ctWhV/AnEL6tMWoybpqIVglOPr1AcYSPdCZxvUt8 W2xQ== X-Gm-Message-State: ACrzQf2KXjeZN5XYeKkMUZC9e9qW+8KM9DWm7SpEolXd1LSwc7aVuTVH IEN6hisY/d5Byh54KLZla3M= X-Google-Smtp-Source: AMsMyM7bTMxCsP9dOI+Bl1xuj1IaaaoIqlOYDL8utEB69BRcDrg0hci5JTHfuZuMGkulrILxqo1MmA== X-Received: by 2002:a65:41ca:0:b0:434:f92f:d711 with SMTP id b10-20020a6541ca000000b00434f92fd711mr45773572pgq.151.1667856986465; Mon, 07 Nov 2022 13:36:26 -0800 (PST) Received: from localhost (fwdproxy-prn-117.fbsv.net. [2a03:2880:ff:75::face:b00c]) by smtp.gmail.com with ESMTPSA id d1-20020a170903230100b00178b9c997e5sm5446350plh.138.2022.11.07.13.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 13:36:25 -0800 (PST) From: Nhat Pham To: senozhatsky@chromium.org Cc: hannes@cmpxchg.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, minchan@kernel.org, ngupta@vflare.org, akpm@linux-foundation.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com Subject: Re: [PATCH 4/5] zsmalloc: Add ops fields to zs_pool to store evict handlers Date: Mon, 7 Nov 2022 13:36:25 -0800 Message-Id: <20221107213625.939660-1-nphamcs@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=M1k2UTfx; spf=pass (imf01.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667856987; a=rsa-sha256; cv=none; b=I09KajmU41M5qIBQWhp5zlcy/Pqi1YjVfZpmEm4p9OluTbHeQXJIHDv8/OL4/SivxCOekk 9H9Xp1mjel5o3HxNeXbNRRB5l2K+XQD7MFclUiQRE1XUsU6Iwai0hIojKRu90EhQbonpUg iL6rln1P3mwLKPU15Xp7HLRIytYUd7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667856987; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0tQ7MqopprIdRhb/IgvKRUjGQBe2LKpMrEFgj2d9jZg=; b=MmO2ls5nwgzA/4CtAGlw2xTjLngOvsddPTlv63GhotHDkslvtPyhoQw7incIfdKz2YzSpo P3m+VXCN+VJD2ImRRKNtEWp48sd0eenkmWVgHIhYvkwrWAn9hyHGjAUSUZbCZ7zxZceLBa 2uPBPQAKuEVXLa08PFIjHMCtHmKhtvY= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B5A8040013 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=M1k2UTfx; spf=pass (imf01.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: zmk7knyf6k9kh1wfptibo6h1dt6t7i9t X-Rspam-User: X-HE-Tag: 1667856987-589700 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: Essentially, the zpool constructor allows us to set things up with a null struct zpool, zpool_ops, or zpool_ops->evict, which we have to handle. A similar null-handling pattern can be observed in zbud (mm/zbud.c) and z3fold (mm/z3fold.c) - see zbud_zpool_evict and zbud_zpool_create for e.g. In particular: 1. pool->zpool_ops is the ops (containing the evict handler zpool_ops->evict) passed into the zpool constructor (zs_zpool_create) 2. pool->ops/zs_zpool_ops (struct zs_ops) is a struct wrapping zs_zpool_evict, which itself is a wrapper for the zpool evict handler (pool->zpool_ops->evict). zs_zpool_evict also handles the case where zpool or zpool_ops is null, or zpool_ops->evict is not defined (i.e return -ENOENT). FWIW, I do think this is quite convoluted. In the long run, we might want to simplify this design, but for this patch series I think it is wise to err on the safe side and follow the other two allocators' design for consistency. That said, while staring at the code again, I found a bug - in the case pool->zpool_ops is null, pool->ops is undefined garbage. The v3 patch will fix that to follow zbud's pattern (pool->ops = NULL in this case).