Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp549418rwb; Mon, 26 Sep 2022 02:40:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Z/0lWA8OsQ9lKYyUK1CyXr7Zf/113AM85BTpM6YUeFbU+1JDpTlhtJFYWNYhCUctWs6co X-Received: by 2002:a63:581e:0:b0:43c:29a0:6390 with SMTP id m30-20020a63581e000000b0043c29a06390mr16768288pgb.552.1664185235273; Mon, 26 Sep 2022 02:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664185235; cv=none; d=google.com; s=arc-20160816; b=xt/EkrMB66DYKxU77CpTl+tAbNYu++WCeT7A7ZyLSYg8fPluVa402STmn84CCTItE5 vDAKmMKNH4WA7wSEhULsHLLybwEdgzHrdtyAbDCmCpdt1WW/5cthkpUav/KXq4ROUXCK 8j4SJPLLZNilR7e9K748rqUfD5F7KncuMvN9VJB79yNTYmw5M0lrZ9vgKmBqCusTSb0g fJjRCwUCVwhDI+23i9IIkI09cYL1HPNu3ZQCW1RH2SaQtc4BmqCEypfKQJ/i9P8xjSDx e1MmBn4C9wGHoT18JhuAwFZWWPBqWjyPbnNNpX17f/wFalw40vcQmrG03sZ/DC6wgWZ/ wqnQ== 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:dkim-signature; bh=a16UwsJjCJ8ct9QxuBqwHjiBFMjsCmZvJCcB9CAGKV8=; b=bpunEOvkzgSMlewtCwtEKU64JUZ0bhXitZPgxAN/mzHbV+z0KDTdwmVNeI/cYO9u0Z Zp5k3QweMy2lMgoL6K3Qbs0PhuHj60PJdDdx1nASVg9vbnx8QPREKztPBAOXCq7NxdX+ yjb9S2zlHoT+lu7/CN5rZN1N8XaZYRELnBQ4rvWzLlccYy2ciypHCh0eor1ocJw80HH/ IO/ocWeLxPc34stz5sAIRLAZR0Xct11rRDwTAZRKv+q+dGO+Hm1g0VlB01T47j+Rm9So bWU9dvvSnMWhUD20CcMt//bmnuoUyCn4PFI9PgWosrbtoK+aE1ZjFK+VBglac0yzNJ2A ZK0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Ldmbl3pL; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k1-20020a17090a3e8100b00202d04a9205si11044574pjc.91.2022.09.26.02.40.23; Mon, 26 Sep 2022 02:40:35 -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=@suse.com header.s=susede1 header.b=Ldmbl3pL; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234573AbiIZI6I (ORCPT + 99 others); Mon, 26 Sep 2022 04:58:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234495AbiIZI6E (ORCPT ); Mon, 26 Sep 2022 04:58:04 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21DAA3DBC9; Mon, 26 Sep 2022 01:58:02 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C36D121F34; Mon, 26 Sep 2022 08:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1664182680; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=a16UwsJjCJ8ct9QxuBqwHjiBFMjsCmZvJCcB9CAGKV8=; b=Ldmbl3pLGFcFRLjiJ9cX2Gq6DNTlW9KFUoPFO9Em11djLCRi0QS113VPvebZvtr6MVZweN on/3J/KdM6KYaSSHbQYcFD9Re6eM1xfTxRZLBktK/DzXLkudV2Md0LlY3L50iBfKIl+15M s4UmD71EnrpY/bwnRVGsFuBncjhBpjQ= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9F4FE13486; Mon, 26 Sep 2022 08:58:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RwesJJhpMWO3ZgAAMHmgww (envelope-from ); Mon, 26 Sep 2022 08:58:00 +0000 Date: Mon, 26 Sep 2022 10:57:59 +0200 From: Michal Hocko To: Florian Westphal Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, vbabka@suse.cz, akpm@linux-foundation.org, urezki@gmail.com, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, Martin Zaharinov Subject: Re: [PATCH mm] mm: fix BUG with kvzalloc+GFP_ATOMIC Message-ID: References: <20220923103858.26729-1-fw@strlen.de> <20220923133512.GE22541@breakpoint.cc> <20220926075639.GA908@breakpoint.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220926075639.GA908@breakpoint.cc> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Mon 26-09-22 09:56:39, Florian Westphal wrote: > Michal Hocko wrote: > > > kvzalloc(GFP_ATOMIC) was perfectly fine, is this illegal again? > > > > kvmalloc has never really supported GFP_ATOMIC semantic. > > It did, you added it: > ce91f6ee5b3b ("mm: kvmalloc does not fallback to vmalloc for incompatible gfp flags") Yes, I am very well aware of this commit and I have to say I wasn't really supper happy about it TBH. Linus has argued this will result in a saner code and in some cases this was true. Later on we really had to add support some extensions beyond GFP_KERNEL. Your change would break those GFP_NOFAIL and NOFS usecases. GFP_NOWAIT and GFP_ATOMIC are explicitly documented as unsupported. One we can do to continue in ce91f6ee5b3b sense is to do this instead diff --git a/mm/util.c b/mm/util.c index 0837570c9225..a27b3fce1f0e 100644 --- a/mm/util.c +++ b/mm/util.c @@ -618,6 +618,10 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node) */ if (ret || size <= PAGE_SIZE) return ret; + + /* non-sleeping allocations are not supported by vmalloc */ + if (!gfpflags_allow_blocking(flags)) + return NULL; /* Don't even allow crazy sizes */ if (unlikely(size > INT_MAX)) { A better option to me seems to be reworking the rhashtable_insert_rehash to not rely on an atomic allocation. I am not familiar with that code but it seems to me that the only reason this allocation mode is used is due to rcu locking around rhashtable_try_insert. Is there any reason we cannot drop the rcu lock, allocate with the full GFP_KERNEL allocation power and retry with the pre allocated object? rhashtable_insert_slow is already doing that to implement its never fail semantic. -- Michal Hocko SUSE Labs