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 510216EC56; Sun, 14 Mar 2021 21:24:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 510216EC56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1615746291; bh=2BxC/AoJZ1K4Wrl0FocpYHPqUdXbRglDjsQP9jNylT4=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=j+deAo8hnT2UqcfPAftJbw9COHPL1s9xOGQWT3XSajuj7X+Je//BAv9WqM5WjI8vK i1v97Qic1KJ/OsiNo5Xmvmi8n3fb59XlCXOQnavtFtQvyUTvw6+nAXMkjjwTaVIYs9 9xG3VH50eWVyFXuuZv5336W0p1flnWM0MRa67MoQ= Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 D3C716EC56 for ; Sun, 14 Mar 2021 21:24:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D3C716EC56 Received: by mail-lj1-f180.google.com with SMTP id y1so13593897ljm.10 for ; Sun, 14 Mar 2021 11:24:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QfMkoy7jrXRL6vc/YYKQU85UiSQ2y2K+gt6YF4QQscw=; b=ovPsRtQ0bFPeWAq+x5+41hmC2ko/rxtdYTHlEQHJSL61yGkXG80QLphzyCSZgXjdSo uqzLS9TUwknUzpqKCpaBNVf3XuSW16bvLwZvy3aVidB7CvPyQGdtINqhmojuStdXX0MG wK5eIkCFKSdsYe4dIGN4eNcB+oE4ZILclzRKW0Kt2EfqLRDegnDQooHclPgzUvfyJQnz zvIPsYBmq7eR3anluKppVZRaR+8G6u/Vzmd1VcfcRrkQU7ZLYXelC+oKdaPf7TTutYeV XxUy2WMcHRAUosX3yBasTzB1h4XLLfyKpWgsbQGMElogaCzkJIqxQMaJ3qcZpbfxNRm+ Oo3g== X-Gm-Message-State: AOAM533VNuO7+/PHBLzy4JUkyZ/BQY3/Y7lvsLtmbYdzMF6PhZJ7/l60 qJ938oq1UzEexkgaHAC0ABdXX95Yyd9TAg== X-Google-Smtp-Source: ABdhPJwGzRUTHLi22Oa8jbHIwyMYu13E2t0zsnleUFux1cMrE+GlpVRP9sNhlHvPqwqnAJVBfPgL4A== X-Received: by 2002:a2e:b011:: with SMTP id y17mr8542163ljk.390.1615746288609; Sun, 14 Mar 2021 11:24:48 -0700 (PDT) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id o14sm2682728ljp.48.2021.03.14.11.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 11:24:47 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id AC8445601FF; Sun, 14 Mar 2021 21:24:46 +0300 (MSK) Date: Sun, 14 Mar 2021 21:24:46 +0300 To: Vladislav Shpilevoy Cc: tml Message-ID: References: <20210310204710.186461-1-gorcunov@gmail.com> <20210310204710.186461-2-gorcunov@gmail.com> <22029d0a-d7b1-ccb6-b928-a7e277e034c0@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <22029d0a-d7b1-ccb6-b928-a7e277e034c0@tarantool.org> User-Agent: Mutt/2.0.5 (2021-01-21) Subject: Re: [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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Sun, Mar 14, 2021 at 05:30:57PM +0100, Vladislav Shpilevoy wrote: > > - assert(delta > 0); > > gc_run_cleanup(); > > gc.cleanup_completed += delta; > > + assert(delta > 0 && gc.cleanup_completed > 0); > > You didn't need to change the assertion. If `delta` is always > positive, and `cleanup_completed` is populated only from `delta`, > it is also positive always. This allows to make sure that gc.cleanup_completed didn't change in gc_run_cleanup in unpredicted way. I'll update if you prefer, sure thing. Force pushed. --- diff --git a/src/box/gc.c b/src/box/gc.c index 1f8cc818d..9af4ef958 100644 --- a/src/box/gc.c +++ b/src/box/gc.c @@ -239,7 +239,7 @@ 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); @@ -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.30.2