Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp667273rdd; Tue, 9 Jan 2024 16:30:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IErRpPKfN92p9GWXezuW8t1flng0AOtMqvrlOmxpvNqHs/KeO90BDQ/TFk9y+C5wh7I++AW X-Received: by 2002:a05:6358:99aa:b0:172:e5d2:c312 with SMTP id j42-20020a05635899aa00b00172e5d2c312mr222187rwb.39.1704846633715; Tue, 09 Jan 2024 16:30:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704846633; cv=none; d=google.com; s=arc-20160816; b=afboLmHULl6UgNendpSgaU+zclcYW2nXmickN77AeQVcVM07k0aWwiD/iCtyG+7YGt zXqN+GKAfCb1nsd4P9e3tDEf64k/eZULRZWuocwB4PsMBXIYdRB16R2DN+LCg9sNSP58 GpNz56YcQqBIOZFptAF0atM92DEvuxIenuIzmu7lSJGNwRBv4nDkvgwKkcVIdCeCtLdG aQYlk9ic1pljse3a3JmqjyUnMtl8KJYmUbzjUzTGxUC72URyl+azgTGvNnUQLweDcCf8 eomuoHydcCKhkDMGC/JnYX0DeuDOmomtyo/vv/uU15ryToKGEqyK8bZWeHEUccZ13HkQ wjBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:cc:to:references :in-reply-to:from:organization:dkim-signature; bh=3UBCSAP+i4rFiL/6w+6TRuBgPaXgWBvM8cIe5uHLFsI=; fh=QeZid2m+uNAd21EQjn/mgwPcViFqD34b1uFNqgLD/Jc=; b=RGDLreG36Kj8TY4tjgFDZeexvfs/ZVv5CEQ6r0VA30QcPKDaXsQexJdw5KSsxW4PnQ X5U6AfiC/z2j+CxfQISOBJAfE671oPHyXm/gzjNenkGbicBM3nxyuF6gOUfBqvdsuiW6 kwCHRDRU+gGd3FKvvESe93B+F0BkXlMnM/e7fiZZ2QHFLP5YaMR8FglpNA/cNa0y6fnz LFqsscWBVS9WUmDWMJ15QQrvRHBqaZ4+B4OggPod55//GQSxyOIbKb62jciTrAKS8HMU IeS5Yhxn+rEFeS1O0sVppHXrtUgSN+jdIqj1DTiUdWsADt+IS3CrB9L1Ac+Tz0smKEFR cH9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="cnD/Opmn"; spf=pass (google.com: domain of linux-kernel+bounces-21580-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21580-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k30-20020a63ba1e000000b005cdf95ddf7esi2458237pgf.350.2024.01.09.16.30.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 16:30:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21580-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="cnD/Opmn"; spf=pass (google.com: domain of linux-kernel+bounces-21580-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21580-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CBD2C2829E3 for ; Wed, 10 Jan 2024 00:30:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B70F16AA0; Wed, 10 Jan 2024 00:29:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cnD/Opmn" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FACC6116 for ; Wed, 10 Jan 2024 00:29:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704846569; h=from:from:reply-to:subject:subject: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=3UBCSAP+i4rFiL/6w+6TRuBgPaXgWBvM8cIe5uHLFsI=; b=cnD/OpmnzbShIlSU4hg2KWUQb1VjAaLDwQEK8s6f1sy0u6NXzbZ/EsvkP/6hBtAmZs/+/k VtWB0pcRhAMsLOqiWDq6fQTXB2A8Vj2QODoBenVakC3zBIOMlRjplPoWD7SIn4erTjETlr iYBpwnm5npwViQotATcc3RGJerXXfTQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-225-rRqSgByQNiiaVW-p7jmNbQ-1; Tue, 09 Jan 2024 19:29:25 -0500 X-MC-Unique: rRqSgByQNiiaVW-p7jmNbQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9EACB82DFE4; Wed, 10 Jan 2024 00:29:25 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 182D6492BC7; Wed, 10 Jan 2024 00:29:24 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <152261521484.30503.16131389653845029164.stgit@warthog.procyon.org.uk> <3465e0c6-f5b2-4c42-95eb-29361481f805@zytor.com> To: Andrew Pinski Cc: dhowells@redhat.com, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 00/45] C++: Convert the kernel to C++ Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1682636.1704846564.1@warthog.procyon.org.uk> Date: Wed, 10 Jan 2024 00:29:24 +0000 Message-ID: <1682637.1704846564@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Andrew Pinski wrote: > Note even in GCC, we disable exceptions and RTTI while building GCC. > This is specifically due to not wanting to use them and use other > methods to do that. > Note GDB on the other hand used to use setjmp/longjmp for their > exception handling in C and I think they moved over to using C++ > exceptions which simplified things there. But as far as I know the > Linux kernel does not use a mechanism like that (I know of copy > from/to user using HW exceptions/error/interrupt handling but that is > a special case only). If we were to allow exception handling, I wonder if we would actually need to throw anything other than a signed long integer (e.g. an error code) and just disable RTTI. Maybe something like: long sys_rename(...) { struct rwsem_lock lock_a, lock_b; struct inode *dir_a, *dir_b; ... try { if (dir_a > dir_b) { lock_a.down_write_killable(dir_a); lock_b.down_write_killable(dir_b); } else { lock_b.down_write_killable(dir_b); lock_a.down_write_killable(dir_a); } } catch (-EINTR) { throw -ERESTARTSYS; } ... } then have a cut-down exception unwinder that only needs to deal with long values. However, I think rolling out exception handling in the kernel might be too big a task, given the huge amount of code involved - however much we might like to avoid all those return value checks. David