From nobody Thu May 16 11:14:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1591224629; cv=none; d=zohomail.com; s=zohoarc; b=XzPNwFaiKDalRwrs1BQ3X7fk7lkBTMiSYZUKZ6dnBV8l1HbrEFtMxMN5AVdg+fE7VesXpPniRPrZ+SsYiVNoJuie+gHKc3+opzMvnPG0odGQG8oHQPSKoimsXcTa84GJC4URwpQOqtVU2PzEjIXa3lY+GTYB6iOasCiyargHLUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591224629; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Pv6QoXrz4ajpX8NND9kalquOGGD9ipkaOR1cFQw36I4=; b=E9A262wi/29xGGshybXnLzQFPodTPie07KEMd/uCgif/yxFap2mTeX7PS1GtnPEkglpT8KOHsocEqXErxcFHSLUEe7I0HwchYJ7ooqaTbGxviZdP2WtCJZWpWN6dXY4XGvnPBUzJMTKFUhlIe1mznVZj2l5i+pq8nqWCIrCAgK4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591224629199395.69895066452216; Wed, 3 Jun 2020 15:50:29 -0700 (PDT) Received: from localhost ([::1]:33170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgcDK-0008UT-8K for importer@patchew.org; Wed, 03 Jun 2020 18:50:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgcCd-00082j-6X; Wed, 03 Jun 2020 18:49:43 -0400 Received: from mail5.windriver.com ([192.103.53.11]:45868 helo=mail5.wrs.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgcCa-0003Ue-L2; Wed, 03 Jun 2020 18:49:41 -0400 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id 053MnFpl018347 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 3 Jun 2020 15:49:25 -0700 Received: from ala-lpggp3.wrs.com (147.11.105.124) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.487.0; Wed, 3 Jun 2020 15:49:04 -0700 From: Joe Slater To: Subject: [PATCH 1/2] lockable: use QLNULL for a null lockable Date: Wed, 3 Jun 2020 15:49:02 -0700 Message-ID: <20200603224903.26268-2-joe.slater@windriver.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603224903.26268-1-joe.slater@windriver.com> References: <20200603224903.26268-1-joe.slater@windriver.com> MIME-Version: 1.0 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.103.53.11; envelope-from=joe.slater@windriver.com; helo=mail5.wrs.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 18:49:36 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allows us to build with -Og and optimizations that do not clean up dead-code. Signed-off-by: Joe Slater to be squished Signed-off-by: Joe Slater --- block/block-backend.c | 4 ++-- block/block-copy.c | 2 +- block/mirror.c | 5 +++-- fsdev/qemu-fsdev-throttle.c | 6 +++--- hw/9pfs/9p.c | 2 +- include/qemu/lockable.h | 3 +++ util/qemu-co-shared-resource.c | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 6936b25..92128e8 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1174,7 +1174,7 @@ static void coroutine_fn blk_wait_while_drained(Block= Backend *blk) =20 if (blk->quiesce_counter && !blk->disable_request_queuing) { blk_dec_in_flight(blk); - qemu_co_queue_wait(&blk->queued_requests, NULL); + qemu_co_queue_wait(&blk->queued_requests, QLNULL); blk_inc_in_flight(blk); } } @@ -2367,7 +2367,7 @@ static void blk_root_drained_end(BdrvChild *child, in= t *drained_end_counter) if (blk->dev_ops && blk->dev_ops->drained_end) { blk->dev_ops->drained_end(blk->dev_opaque); } - while (qemu_co_enter_next(&blk->queued_requests, NULL)) { + while (qemu_co_enter_next(&blk->queued_requests, QLNULL)) { /* Resume all queued requests */ } } diff --git a/block/block-copy.c b/block/block-copy.c index bb8d056..8de0b54 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -120,7 +120,7 @@ static bool coroutine_fn block_copy_wait_one(BlockCopyS= tate *s, int64_t offset, return false; } =20 - qemu_co_queue_wait(&task->wait_queue, NULL); + qemu_co_queue_wait(&task->wait_queue, QLNULL); =20 return true; } diff --git a/block/mirror.c b/block/mirror.c index e8e8844..76c082d2 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -28,6 +28,7 @@ #define MAX_IO_BYTES (1 << 20) /* 1 Mb */ #define DEFAULT_MIRROR_BUF_SIZE (MAX_IN_FLIGHT * MAX_IO_BYTES) =20 + /* The mirroring buffer is a list of granularity-sized chunks. * Free chunks are organized in a list. */ @@ -157,7 +158,7 @@ static void coroutine_fn mirror_wait_on_conflicts(Mirro= rOp *self, if (ranges_overlap(self_start_chunk, self_nb_chunks, op_start_chunk, op_nb_chunks)) { - qemu_co_queue_wait(&op->waiting_requests, NULL); + qemu_co_queue_wait(&op->waiting_requests, QLNULL); break; } } @@ -297,7 +298,7 @@ mirror_wait_for_any_operation(MirrorBlockJob *s, bool a= ctive) if (!op->is_pseudo_op && op->is_in_flight && op->is_active_write =3D=3D active) { - qemu_co_queue_wait(&op->waiting_requests, NULL); + qemu_co_queue_wait(&op->waiting_requests, QLNULL); return; } } diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 5c83a1c..78d256d 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -22,13 +22,13 @@ static void fsdev_throttle_read_timer_cb(void *opaque) { FsThrottle *fst =3D opaque; - qemu_co_enter_next(&fst->throttled_reqs[false], NULL); + qemu_co_enter_next(&fst->throttled_reqs[false], QLNULL); } =20 static void fsdev_throttle_write_timer_cb(void *opaque) { FsThrottle *fst =3D opaque; - qemu_co_enter_next(&fst->throttled_reqs[true], NULL); + qemu_co_enter_next(&fst->throttled_reqs[true], QLNULL); } =20 int fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **err= p) @@ -100,7 +100,7 @@ void coroutine_fn fsdev_co_throttle_request(FsThrottle = *fst, bool is_write, if (throttle_enabled(&fst->cfg)) { if (throttle_schedule_timer(&fst->ts, &fst->tt, is_write) || !qemu_co_queue_empty(&fst->throttled_reqs[is_write])) { - qemu_co_queue_wait(&fst->throttled_reqs[is_write], NULL); + qemu_co_queue_wait(&fst->throttled_reqs[is_write], QLNULL); } =20 throttle_account(&fst->ts, is_write, iov_size(iov, iovcnt)); diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 45a788f..35976e2 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2888,7 +2888,7 @@ static void coroutine_fn v9fs_flush(void *opaque) /* * Wait for pdu to complete. */ - qemu_co_queue_wait(&cancel_pdu->complete, NULL); + qemu_co_queue_wait(&cancel_pdu->complete, QLNULL); if (!qemu_co_queue_next(&cancel_pdu->complete)) { cancel_pdu->cancelled =3D 0; pdu_free(cancel_pdu); diff --git a/include/qemu/lockable.h b/include/qemu/lockable.h index b620023..7f7aebb 100644 --- a/include/qemu/lockable.h +++ b/include/qemu/lockable.h @@ -24,6 +24,9 @@ struct QemuLockable { QemuLockUnlockFunc *unlock; }; =20 +#define QLNULL ((QemuLockable *)0) + + /* This function gives an error if an invalid, non-NULL pointer type is pa= ssed * to QEMU_MAKE_LOCKABLE. For optimized builds, we can rely on dead-code = elimination * from the compiler, and give the errors already at link time. diff --git a/util/qemu-co-shared-resource.c b/util/qemu-co-shared-resource.c index 1c83cd9..7423ea4 100644 --- a/util/qemu-co-shared-resource.c +++ b/util/qemu-co-shared-resource.c @@ -64,7 +64,7 @@ void coroutine_fn co_get_from_shres(SharedResource *s, ui= nt64_t n) { assert(n <=3D s->total); while (!co_try_get_from_shres(s, n)) { - qemu_co_queue_wait(&s->queue, NULL); + qemu_co_queue_wait(&s->queue, QLNULL); } } =20 --=20 2.7.4 From nobody Thu May 16 11:14:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1591225304; cv=none; d=zohomail.com; s=zohoarc; b=G0cDNWA4dNX01/IJmOQqvVtojcMJyZfSC9Sg4FEotXFStoJrgF25CMxrdgQboew2F7A7Mlcrsi3p7zJSx8WEwlqi8ekLuvpK9UmoU9Ck5TsPzvPiSYhvP+i5O9nUxjahuMo2poH3LEsLXUe/ohUMDRpEEadROZ3M69FW8lt3D1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591225304; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4M9qbr7RYgC/oLIhnGcwQzxX+7se0fryefs5prYZkuc=; b=H3s6grVJrMqAheR1oJoogHQ8z7m4CnEyEz98+llFieSJXJvHi0lu5iSpdaMymJjtVnAUhwk8l7riOo4AWpgISj6uWc4QdCiE8FywHAfeRmqY+gsNELb4ET7L+FjiktvI2PuTlotGWM8zJyP7TLzGtoEyo+bj/J1ALYI/rl9zfgg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159122530453435.481060996194856; Wed, 3 Jun 2020 16:01:44 -0700 (PDT) Received: from localhost ([::1]:39690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgcOF-0004Ag-5s for importer@patchew.org; Wed, 03 Jun 2020 19:01:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgcMk-0002aM-8T; Wed, 03 Jun 2020 19:00:10 -0400 Received: from mail.windriver.com ([147.11.1.11]:40154) by eggs.gnu.org with esmtps (TLS1.1:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jgcMh-0005bh-Oi; Wed, 03 Jun 2020 19:00:09 -0400 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail.windriver.com (8.15.2/8.15.2) with ESMTPS id 053MnQZl008733 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 3 Jun 2020 15:49:27 -0700 (PDT) Received: from ala-lpggp3.wrs.com (147.11.105.124) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.487.0; Wed, 3 Jun 2020 15:49:26 -0700 From: Joe Slater To: Subject: [PATCH 2/2] lockable: do not rely on optimization for null lockables Date: Wed, 3 Jun 2020 15:49:03 -0700 Message-ID: <20200603224903.26268-3-joe.slater@windriver.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603224903.26268-1-joe.slater@windriver.com> References: <20200603224903.26268-1-joe.slater@windriver.com> MIME-Version: 1.0 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=147.11.1.11; envelope-from=joe.slater@windriver.com; helo=mail.windriver.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 18:49:27 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If we use QLNULL for null lockables, we can always use referencing unknown_lock_type as a link time error indicator. Signed-off-by: Joe Slater --- include/qemu/lockable.h | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/include/qemu/lockable.h b/include/qemu/lockable.h index 7f7aebb..7fc5750 100644 --- a/include/qemu/lockable.h +++ b/include/qemu/lockable.h @@ -24,21 +24,14 @@ struct QemuLockable { QemuLockUnlockFunc *unlock; }; =20 -#define QLNULL ((QemuLockable *)0) - - -/* This function gives an error if an invalid, non-NULL pointer type is pa= ssed - * to QEMU_MAKE_LOCKABLE. For optimized builds, we can rely on dead-code = elimination - * from the compiler, and give the errors already at link time. +/* + * If unknown_lock_type() is referenced, it means we have tried to passed= something + * not recognized as lockable to the macros below. Use QLNULL to intenti= onally pass + * a null lockable. */ -#if defined(__OPTIMIZE__) && !defined(__SANITIZE_ADDRESS__) +#define QLNULL ((QemuLockable *)0) void unknown_lock_type(void *); -#else -static inline void unknown_lock_type(void *unused) -{ - abort(); -} -#endif + =20 static inline __attribute__((__always_inline__)) QemuLockable * qemu_make_lockable(void *x, QemuLockable *lockable) --=20 2.7.4