Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp343524lqp; Thu, 4 Apr 2024 15:18:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0CuUUTRVyCI+isMnGKKpj+pHCR9SS3OG9MKEWW/1J2FZ3fi/mhQPaemHqh2zntPWpE11D5xF0Jn44pF622enW46JSh0TLZWFpKhO7Bw== X-Google-Smtp-Source: AGHT+IFtGc+vpsS5qVr5wDEGOCBMw3XoV0ubeNLLTl92SY2bPI4vgCBEbPbYzCOQX8lj7oHCzZ1R X-Received: by 2002:a50:ab5b:0:b0:568:c621:c496 with SMTP id t27-20020a50ab5b000000b00568c621c496mr560440edc.42.1712269091410; Thu, 04 Apr 2024 15:18:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712269091; cv=pass; d=google.com; s=arc-20160816; b=CVLSw4O93d88oPttLcMcVjmuVqsqssNG7z49+OQYFQuBPaXCrsBdLptipFo0mRTz94 qqXgMnF7OhT/FUn/i32DTE8I2pCwN9msLUe4SmsfE7J31Ht9MTBCRJL3yGVQWMYi+u+d e4CcyGh1AjwJ6as5cEX8Prl+Zk99N37cIfmpaqzyzaZ2Q/d1KdD2Fpgl3FdJKFFnJl02 TmDI1djAmv3qrhrmMSBUVsRgAEzBKZpN2zI7pDVRVxHgenqNXrqUid+npcfb+0tUBHfx +EcNTmNhJ45bYr5F208FwfIXhh+hamtDmYQvEBNiL1H+FFccou/fMO6/0j2URZ5GkhH6 3IOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=eIW+Z3FuH4Tlrbj9QrjroPzWQnEb4hQ4AxEw1tDZfk4=; fh=RKYU4ICElMgGpRzE3oNFXtH3pnDQp6zdAZDlJWHp9XE=; b=BgvrPgE9az0KsQgSMFkKXCHcgXvGji/jKkJdI03H4b5mWulTfBhfuXFnpq9JeoXrsG rSkNsM0pyDchgjnt/wTqr80iP7zYNgUyd+ey+LsvpplZWvu3NPg+FRQpcDV9hCVg1w3V //Cy1jRLe4N9hHg5AFcITKQqxwWSxGN0IqSnaSQnWFAqqzDXIRmARRYia0qk4T0Pu0MN f0pwCJ4h2NiVnKnqg0BwK0UqkGDZaFpBoCXwruztrZpaY9t5+gc2Hgn70ob30yCzYMLM mfvQvyJS6x0f8aottlb43iTRcfLRlmu57c8vYwfviFrGNYn2Hap+pg/8V5d3JR6OTjdS fQXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=iNpgHmou; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-nfs+bounces-2649-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2649-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id o3-20020a509b03000000b0056c19240503si80726edi.684.2024.04.04.15.18.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 15:18:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-2649-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=iNpgHmou; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-nfs+bounces-2649-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2649-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AFC921F24AB1 for ; Thu, 4 Apr 2024 22:18:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6ABA313C662; Thu, 4 Apr 2024 22:18:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iNpgHmou" X-Original-To: linux-nfs@vger.kernel.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05F0A13C3F6 for ; Thu, 4 Apr 2024 22:17:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712269081; cv=none; b=j52a+oLttvDuRZ28lY5YHN8lvWwr9R7xa9c9bDKGvecCdmlTkZM6FIp9LY6p0SMbP056WAvG7rGel0ouhnpiNGDGfvd3YgiU8URmNDZZdxZ+ABR+REhPW5j35eBxI9UfRC2qmEeOY/Ot6toltWdqjAurtHy3MHU5a6OsivfsoHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712269081; c=relaxed/simple; bh=RZPrq+xVDjiyzuvgmiC5bztMCL91wQIMW6JQhQhfvYY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=YcEP+wzhB4yXYyEqPlV1ANgUiiDh38SHo85u7QcMqypdtokubuzrGo3JIsSOpzPICzu7cvf35etIMjSjICbp7l9u5ssg2yaaHYgUIKdKFayrh4q3xtxx0NxWAVYb/UM5DU8NMw4trI96EaasFzvYsJmWsW8eT2AJOqfncUe96Dk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=iNpgHmou; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4162ad6453aso8119585e9.0 for ; Thu, 04 Apr 2024 15:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712269077; x=1712873877; darn=vger.kernel.org; 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=eIW+Z3FuH4Tlrbj9QrjroPzWQnEb4hQ4AxEw1tDZfk4=; b=iNpgHmouikM3eS2bzDsViRnQPf4IYT0AntRq/pLUycBts1tEtNDBhLAHPWLbGGQuwD QJtB2nqOmcrDZKQqkypAxU9t8BXasLVzM76U6doxh0UD6M0mrI/XgijigKuOcMI2NCIb whmis5i9jCy0XZKIvDNYWGW+znPQeHBEMsfX8rggozuXIuCHf0B+o1YIbhjdkYuLbC6k nmWR9tyq0QFPwh7UUDhI4p73EwefaEhKQVvrdC/li4M77bvJ/3+wYenQP3FJrzs+WVyB h/Tam1ckIRELByLvoQC8mEYZ6O8sMXwbWpK4qyuHRrWaDSukD/B1KlHnI6ojMiGvDvbK uIeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712269077; x=1712873877; 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=eIW+Z3FuH4Tlrbj9QrjroPzWQnEb4hQ4AxEw1tDZfk4=; b=wWhGs9dgBetKyrzigM4Eh2yZJLuBT8PVICmD6Cv7qDxn3ATplhzdND0hoitjD6X8lx lEMYNp4I1algF6pOkfLXUGKWnqP8HIx3ND3emuygt3TPPNkwVUmUImeEtRSj/KhvZUtS iKgwDJhQJ6ty1kRavLV7tyOowx6u3dI+5HB5lmLhOT7YUaYi04jA+KrgLgyp6aeHNDVm YXes+k5WZqAv0FIYc9GSvA0kpS8K615Rx4Mg0IMUdZ9rQsLKyryFrld6PLzN5XwvMTgo hXDNxX30SuMsaA0iTFxKsBUfF5NyEvZUa+OlukJ/B0AhGBOQFZEUMGH0l8fGm/Jua2Cu Xtig== X-Forwarded-Encrypted: i=1; AJvYcCWOaZhPMAQo7e8fSHYDTFUfxI7GqMt360z7EashNR9rTRwZhkMJuL6vGAPCNSVWw3xAKhJdc1phic4H3M9MLiar6/U6ZBdqpvuw X-Gm-Message-State: AOJu0Yyc7HycolAbK2nufKzmbNtppveknyrIWIFvMlx3nq7MFrv52bGv Fmd9YOaeHinDJj/9ftnLsck0a/6z467v6mIVrvuFfNVAEacqN8D4++7ubwMmu3GrjfwJ4efz1WK S3DKBrG8ZH7Q1Grc+p4ptUoCNsPl5QpCi4FBu X-Received: by 2002:a5d:56cd:0:b0:343:a117:7d2 with SMTP id m13-20020a5d56cd000000b00343a11707d2mr434133wrw.71.1712269077043; Thu, 04 Apr 2024 15:17:57 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240404165404.3805498-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 4 Apr 2024 15:17:43 -0700 Message-ID: Subject: Re: [PATCH 1/1] mm: change inlined allocation helpers to account at the call site To: Matthew Wilcox Cc: akpm@linux-foundation.org, joro@8bytes.org, will@kernel.org, trond.myklebust@hammerspace.com, anna@kernel.org, arnd@arndb.de, herbert@gondor.apana.org.au, davem@davemloft.net, jikos@kernel.org, benjamin.tissoires@redhat.com, tytso@mit.edu, jack@suse.com, dennis@kernel.org, tj@kernel.org, cl@linux.com, jakub@cloudflare.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, vbabka@suse.cz, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev, linux-arch@vger.kernel.org, linux-crypto@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-security-module@vger.kernel.org, kent.overstreet@linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 4, 2024 at 10:08=E2=80=AFAM Suren Baghdasaryan wrote: > > On Thu, Apr 4, 2024 at 10:04=E2=80=AFAM Matthew Wilcox wrote: > > > > On Thu, Apr 04, 2024 at 09:54:04AM -0700, Suren Baghdasaryan wrote: > > > +++ b/include/linux/dma-fence-chain.h > > > @@ -86,10 +86,7 @@ dma_fence_chain_contained(struct dma_fence *fence) > > > * > > > * Returns a new struct dma_fence_chain object or NULL on failure. > > > */ > > > -static inline struct dma_fence_chain *dma_fence_chain_alloc(void) > > > -{ > > > - return kmalloc(sizeof(struct dma_fence_chain), GFP_KERNEL); > > > -}; > > > +#define dma_fence_chain_alloc() kmalloc(sizeof(struct dma_fence= _chain), GFP_KERNEL) > > > > You've removed some typesafety here. Before, if I wrote: > > > > struct page *page =3D dma_fence_chain_alloc(); > > > > the compiler would warn me that I've done something stupid. Now it > > can't tell. Suggest perhaps: > > > > #define dma_fence_chain_alloc() = \ > > (struct dma_fence_chain *)kmalloc(sizeof(struct dma_fence_chain= ), \ > > GFP_KERNEL) > > > > but maybe there's a better way of doing that. There are a few other > > occurrences of the same problem in this monster patch. > > Got your point. Ironically, checkpatch generates warnings for these type casts: WARNING: unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html #425: FILE: include/linux/dma-fence-chain.h:90: + ((struct dma_fence_chain *)kmalloc(sizeof(struct dma_fence_chain), GFP_KERNEL)) I guess I can safely ignore them in this case (since we cast to the expected type)? > > > > > > +++ b/include/linux/hid_bpf.h > > > @@ -149,10 +149,7 @@ static inline int hid_bpf_connect_device(struct = hid_device *hdev) { return 0; } > > > static inline void hid_bpf_disconnect_device(struct hid_device *hdev= ) {} > > > static inline void hid_bpf_destroy_device(struct hid_device *hid) {} > > > static inline void hid_bpf_device_init(struct hid_device *hid) {} > > > -static inline u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, = u8 *rdesc, unsigned int *size) > > > -{ > > > - return kmemdup(rdesc, *size, GFP_KERNEL); > > > -} > > > +#define call_hid_bpf_rdesc_fixup(_hdev, _rdesc, _size) kmemdup(_rdes= c, *(_size), GFP_KERNEL) > > > > here > > > > > -static inline handle_t *jbd2_alloc_handle(gfp_t gfp_flags) > > > -{ > > > - return kmem_cache_zalloc(jbd2_handle_cache, gfp_flags); > > > -} > > > +#define jbd2_alloc_handle(_gfp_flags) kmem_cache_zalloc(jbd2_= handle_cache, _gfp_flags) > > > > here > > > > > +++ b/include/linux/skmsg.h > > > @@ -410,11 +410,8 @@ void sk_psock_stop_verdict(struct sock *sk, stru= ct sk_psock *psock); > > > int sk_psock_msg_verdict(struct sock *sk, struct sk_psock *psock, > > > struct sk_msg *msg); > > > > > > -static inline struct sk_psock_link *sk_psock_init_link(void) > > > -{ > > > - return kzalloc(sizeof(struct sk_psock_link), > > > - GFP_ATOMIC | __GFP_NOWARN); > > > -} > > > +#define sk_psock_init_link() \ > > > + kzalloc(sizeof(struct sk_psock_link), GFP_ATOMIC | __GF= P_NOWARN) > > > > here > > > > ... I kind of gave up at this point. You'll want to audit for yourself > > anyway ;-) > > Yes, I'll go over it and will make the required changes. Thanks for > looking into it! > Suren.