Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1182387imm; Wed, 23 May 2018 11:36:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrdJtD2hTuNWcwqZmdmow4BQrQdU3xd/UHa7TY/hV0t4qtPle+HkzbZEbeGoTtLw+ez9jgf X-Received: by 2002:a62:883:: with SMTP id 3-v6mr4028753pfi.154.1527100616820; Wed, 23 May 2018 11:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527100616; cv=none; d=google.com; s=arc-20160816; b=ZD76XcQ1sOZCvejRXeGhh8IgnDvtyE7QVkEwtOmIeEAxpwfIpCvU9T1utpjb591MG0 n5hOnUzrYf1cxDahpXDW3VBV4AD/QvB6ly80GyB4Zu9NHKKph3ZPUSVZIPYLRnbaRuJG QFdwCHPzNgcDNFnXULktNmwfOvWfWkAldDLkb8AyIE1XQR+dAoat5/pnmOkSi9vdJBr7 z276Ri3lA5l101n+N1ecJU6iu2Uew0c2pEBu2fYryD5SOzAsoz6B9g+GXiiKvkePnUFD +6eERmqHVJl+p2f9aManRAGNAeI8eBd29iqgDygKwt4VVJdXOcUUvTtEG2vcUEPGJWqV NP5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=RmLjFgUm4hQ/m+4n8YdCjGP7UdQK8bSx40fPl/53w0Y=; b=XsxBs+6XsjiM4AZmceEaN2HZm+13PBCWMNkKU5UcZZxWIwFgCP/M9giYgAYVelzFIJ cSW81FBRexh4yroaRcpEONJcxn7BtstQdfgt3qSWfOXTn//ZMrHlfgOOHC1GPKkdRnno UnrBvDen6MVQLLH4OzWxr3kiuckobOq70bB5VGXvf0yiyEncHNbUlYWWRzSVorkQ2B1x ND7TQNfx6IOy+AqRWcEUaqMJKkjh3Z2uJ6ZVtciZeyhAG5yjKKI+sYMp6/qwvDoGoq+E /5xJG5Fou1BNdKrDPvp41FFrm9LIOduLpi1nwZX1VAkXfO1960sTd4PRR39OpVHn0wlG VQvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=eXSr+AKW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l12-v6si18983628plc.545.2018.05.23.11.36.42; Wed, 23 May 2018 11:36:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=eXSr+AKW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934019AbeEWSgK (ORCPT + 99 others); Wed, 23 May 2018 14:36:10 -0400 Received: from mail-io0-f172.google.com ([209.85.223.172]:35814 "EHLO mail-io0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933291AbeEWSgH (ORCPT ); Wed, 23 May 2018 14:36:07 -0400 Received: by mail-io0-f172.google.com with SMTP id g1-v6so23995015iob.2; Wed, 23 May 2018 11:36:07 -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=RmLjFgUm4hQ/m+4n8YdCjGP7UdQK8bSx40fPl/53w0Y=; b=eXSr+AKWEPFk4xD5I4LAsD/26atieVJcf4Tc3NpIKP7pIfBukZYst0tcl9TqC1qNto 8pYD8Et0ya+WMW2zhfyJpycw0jiFc+Dz5tRVd7EmcK4CGikkZ8AlYUWF0Mm95XuhQZrT nZgQHn4svGFQDvq5/LolsexjamOeF4Jc7aQq0= 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=RmLjFgUm4hQ/m+4n8YdCjGP7UdQK8bSx40fPl/53w0Y=; b=IedwfJyR9GMt522yxDv2PmjsH5cRBQEo2IqzBlSzMNLLRrCbOSkeVFeV/R9tyTNYMN 9rzOwWF06QMGdAWGpvHau43P35fyfbrpj8QtGon993ethAB9EGwygIzKgMf/VMG1r8Pf byyQGgS7N8oUa6/Q0+fM1IgRNeT0Y/M/W0CaCPlG6QwU417fxee+C+mwf8uoTzW3fCoY terXFOVi6KFOXYSiPSBn//mJLAvQdldtwZ3loVhzVrfbLEVHM5nA1txdkviDLky7JEDf X8s+bPkmv3XLDD0lx/VH0BrnA99+5/nw3/jrmamzZpdamXK90wxKNFBj0ltgR1NgllUF 7BHw== X-Gm-Message-State: ALKqPwcf3AS97hNjqzx8PH5fxXgK4TQ7nm0cReqCjRYW8x+uT8Ttp6vG bO+k/Md249gDa4qUDe05lgwvA32a09IYOP5jpNY= X-Received: by 2002:a6b:ce15:: with SMTP id p21-v6mr3589473iob.257.1527100566525; Wed, 23 May 2018 11:36:06 -0700 (PDT) MIME-Version: 1.0 References: <20180523172500.anfvmjtumww65ief@linux-n805> In-Reply-To: <20180523172500.anfvmjtumww65ief@linux-n805> From: Linus Torvalds Date: Wed, 23 May 2018 11:35:55 -0700 Message-ID: Subject: Re: semantics of rhashtable and sysvipc To: Davidlohr Bueso , Thomas Graf , Herbert Xu Cc: Andrew Morton , Manfred Spraul , guillaume.knispel@supersonicimagine.com, Linux API , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 23, 2018 at 10:41 AM Davidlohr Bueso wrote: > The second alternative would be to add a BUG_ON() if the initialization fails > and we get rid of all the tables_initialized hack. I see absolutely no value in an early boot BUG_ON(). Either we know the allocation cannot fail - which is perfectly fine at bootup, and is a common pattern - or it can fail and we need to handle it. In neither case is the BUG_ON() appropriate. So I'm perfectly fine with getting rid of 'tables_initialized'. But no, not with a BUG_ON(). If you cannot guarantee that the allocation works (using __GFP_NOFAIL is ok, for example - but it only works with small allocations), then you need to handle the allocation failure. I refuse to see more of the shit-for-brains kind of "I can't be bothered to handle error cases" BUG_ON() stuff. And I also am not in the least interested in "this cannot possibly happen" BUG_ON() code. One option is to make rhashtable_alloc() shrink the allocation and try again if it fails, and then you *can* do __GFP_NOFAIL eventually. In fact, it can validly be argued that rhashtable_init() is just buggy as-is. The whole *point* olf that function is to size things appropriately, and returning -ENOMEM obviously means that it didn't do its job. Linus