From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 2B09E6EC59; Wed, 10 Mar 2021 23:47:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2B09E6EC59 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1615409273; bh=dfIDO5p6IQK5dRgEYif2XpRJ5xsX1zLzNjh00dfXIqg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=wgZuM38G0FcvSgR4J0Cnkd9FreNkspv1UhfWog6QaV7OUbk3fUdPf3bv5XGfulsck 8zFyDAr5myx5dCdxSt1+sweBPPYt+Bj6+5wXZJC8WIg+EKDr/Tc9wvw1f4HRr7DZhV 3MCjiwx0BbBrNciH/puP0H1BTbbvejoMibOllTxI= Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id B3B1A6EC59 for ; Wed, 10 Mar 2021 23:47:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B3B1A6EC59 Received: by mail-lf1-f54.google.com with SMTP id f1so35856960lfu.3 for ; Wed, 10 Mar 2021 12:47:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ATw9zfkcnVObQhAy151ZGNKD6XVffNSkEBSAq06dXqc=; b=okBNHfEcG3jhUTDGm+wnbvMb+wvS0Ujbw30y1YZGyX737+Pq4tUlSkPlHrta6fH6iB F6lLOV+YzlmR2q9Mkz6HBYPxZSzr1kGpx3n+s8LpBmVmRozEfzMjsPgHiKQZ9wjIZ4z6 /EsLkYtcEAINCQB2DFkEh0e5Ray4m//UFC3L9Ue8L+QNH/nPmXc5KY8yCdpDlmCWl08j 39IzsuLlIMnpkcDr6h/QM3kLcPre6XEU9zWm87YLiwIwYdybaUXZrAKCafnz30MWAiFB phyo0Us7fVCTNe6bp2MmL0LAtrefo7BbAT0xEc9/mC4ktNmaYN7e8fglgRYV8Z8pi1Yn UqhA== X-Gm-Message-State: AOAM530CW4ld38cPCMv30h1Z//1kEnipfvO9UJf5D4FRLTyNhFbUAeoa JYBulQt5bLC+qI28Lg6yoa0qj2WU08gjPQ== X-Google-Smtp-Source: ABdhPJyNdoO0Kbr0uFGBR7zDAbV1RfsS56qXC2s7tEgYnD24bIC99OLVzNqx3LcP3gtoOs1iOyp4Rw== X-Received: by 2002:a19:4cc5:: with SMTP id z188mr194390lfa.242.1615409250725; Wed, 10 Mar 2021 12:47:30 -0800 (PST) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id j1sm124014lfb.85.2021.03.10.12.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 12:47:29 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 28943560108; Wed, 10 Mar 2021 23:47:17 +0300 (MSK) To: tml Date: Wed, 10 Mar 2021 23:47:09 +0300 Message-Id: <20210310204710.186461-2-gorcunov@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210310204710.186461-1-gorcunov@gmail.com> References: <20210310204710.186461-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/2] gc: use wide integer for schedule counting X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Currently we use unsined int for "cleanup" schedule counting, this is safe while this routine is not called too often. Still there is a chance to hit a number wrap on code modification because there is no strict rule on how to use this garbage collector. Lets use wide integers instead, we have only one gc instance and such approach eliminates potential problems in future (actually this should had been done from the beginning since the current gc code flow developed without wrapping in mind). In-scope-of #5806 Signed-off-by: Cyrill Gorcunov --- src/box/gc.c | 6 +++--- src/box/gc.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/box/gc.c b/src/box/gc.c index 1f8cc818d..86c229c34 100644 --- a/src/box/gc.c +++ b/src/box/gc.c @@ -239,15 +239,15 @@ gc_cleanup_fiber_f(va_list ap) { (void)ap; while (!fiber_is_cancelled()) { - int delta = gc.cleanup_scheduled - gc.cleanup_completed; + int64_t delta = gc.cleanup_scheduled - gc.cleanup_completed; if (delta == 0) { /* No pending garbage collection. */ fiber_sleep(TIMEOUT_INFINITY); continue; } - assert(delta > 0); gc_run_cleanup(); gc.cleanup_completed += delta; + assert(delta > 0 && gc.cleanup_completed > 0); fiber_cond_signal(&gc.cleanup_cond); } return 0; @@ -278,7 +278,7 @@ gc_schedule_cleanup(void) static void gc_wait_cleanup(void) { - unsigned scheduled = gc.cleanup_scheduled; + int64_t scheduled = gc.cleanup_scheduled; while (gc.cleanup_completed < scheduled) fiber_cond_wait(&gc.cleanup_cond); } diff --git a/src/box/gc.h b/src/box/gc.h index 829aaf479..2a568c5f9 100644 --- a/src/box/gc.h +++ b/src/box/gc.h @@ -146,7 +146,7 @@ struct gc_state { * sleep until @completed reaches the value of @scheduled * taken at that moment of time. */ - unsigned cleanup_completed, cleanup_scheduled; + int64_t cleanup_completed, cleanup_scheduled; /** * Set if there's a fiber making a checkpoint right now. */ -- 2.29.2