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 E161271749B; Tue, 5 Dec 2023 15:59:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E161271749B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1701781192; bh=nIb2gw2XOYr0f7Jhr/DfAMnByM6nbvTtXvBkwmzMvN8=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Rf98tvZvufpBsEzE4m7UkLuLK9PYz+yjtf0GBiLImSag6rBt8v0U0VmvRSvGG6TFN DjkT1S2gLeRvdNZlVwYvwOPhKSL/1MnmEdSwmqkuq5GiBT61HFWFhVD+dko7YVTZJv ArTtLAUtF3xni4UJzk5eg6ClcEDPdOlQg8+ut1LQ= Received: from smtp38.i.mail.ru (smtp38.i.mail.ru [95.163.41.79]) (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 dev.tarantool.org (Postfix) with ESMTPS id 80C5E716A53 for ; Tue, 5 Dec 2023 15:59:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 80C5E716A53 Received: by smtp38.i.mail.ru with esmtpa (envelope-from ) id 1rAV1h-00DbSh-11; Tue, 05 Dec 2023 15:59:49 +0300 Date: Tue, 5 Dec 2023 12:59:01 +0000 To: Sergey Kaplun Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD91486559A3ABF84E7CB0A098B493E0346EE397C45C3170F78182A05F53808504072E902AA03D188F265A5F5C9A2BC5E50A08D623A78022B61FB3E6B43E02872B0 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE727FD6E7FC3A8F857EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006370CE4B4B08BC34B6C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8DD2AEADC1AB53727FC3EEBCAD36CBFD7117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18F04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEB1593CA6EC85F86DCFA063A519E5965DD8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE3457EE4B4996FC546AD7EC71F1DB88427C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CA9FF340AA05FB58C2E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89FB26E97DCB74E625242539A7722CA490CB5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5707EA187E7666F581443ADCD1303439DFC72FAD20FC545BAF87CCE6106E1FC07E67D4AC08A07B9B0CE135D2742255B35CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF3E10D971AF01C827EB16E3CBD0C92D1ABCDDF027A0E799332DA7917898D6FC738FF2D56E53A087289157FEB932BFB23D7C86976E21F44E112536F186369DD832A74DFFEFA5DC0E7F02C26D483E81D6BEECAEF3E2CCC1ED8C383653B6C8D9AE0FD16FCAA6493B703A X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojJEmydpeiNq/IjTu99Lcrhw== X-Mailru-Sender: 2FEBA92C8E508479FE7B9A1DF348D5311C63E633A6BE34201BEE30C8393B568230513CE0030DFCD02326FE6F2A341ACE0FB9F97486540B4CD9E8847AB8CFED4D9ABF8A61C016C2CFB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 2/2] test: rewrite sysprof test using managed execution 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, On 05.12.23, Sergey Kaplun wrote: > Hi, Igor! > Thanks for the fixes! > Please, consider my comments below. > > > > > > > > > > > > +#define STREAM_BUFFER_SIZE (8 * 1024 * 1024) > > > > > +#define DEVNULL -1 > > > > > > `DEVNULL` name is misleading (like we've actually opened `/dev/null`). > > > Maybe `DUMMY_FD` is better? Also, I suppose we can drop the `fd` field > > > at all. We can just use static structure in this translation unit and > > > compare pointer against it, so there is no need for an additional field > > > fd in the structure itself. > > > > I see little reasoning in this suggestion: the approach with the > > structure is quite straight-forward and copied from another sysprof test > > implemented in C. Re naming: I prefer to leave it as is. > > I don't get why it is straight-forward. This approach with unused fields > is just misleading. In > the `fd` field is > used since the "/dev/null" is opened and data written to it. > > Also, since we can use custom writer, that test may be updated wo using > `fd` too. But this should be done as a separate refactoring patch. > > > > > In general, your nit is nice, but I believe it should be applied > > for the patch moving tricks to utils library. > > I don't see any relations with ptrace here. It's just the usage of > sysprof's C API. Well, I've finally got your original idea. Here it is: ================================================================================ diff --git a/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c b/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c index 6bf7562f..8967abc4 100644 --- a/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c +++ b/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c @@ -53,35 +53,26 @@ extern void *lj_ff_tostring(void); extern void *lj_fff_res1(void); -/* Sysprof "/dev/null" stream helpers. {{{ */ +/* Sysprof dummy stream helpers. {{{ */ /* * Yep, 8Mb. Tuned in order not to bother the platform with too * often flushes. */ #define STREAM_BUFFER_SIZE (8 * 1024 * 1024) -#define DEVNULL -1 -struct devnull_ctx { - /* - * XXX: Dummy file descriptor to be used as "/dev/null" - * context indicator in writer and on_stop callback. - */ - int fd; +struct dummy_ctx { /* Buffer for data recorded by sysprof. */ uint8_t buf[STREAM_BUFFER_SIZE]; }; +static struct dummy_ctx context; + static int stream_new(struct luam_Sysprof_Options *options) { - struct devnull_ctx *ctx = calloc(1, sizeof(struct devnull_ctx)); - if (ctx == NULL) - return PROFILE_ERRIO; - - /* Set "/dev/null" context indicator. */ - ctx->fd = DEVNULL; - options->ctx = ctx; - options->buf = ctx->buf; + /* Set dummy context. */ + options->ctx = &context; + options->buf = (uint8_t *)&context.buf; options->len = STREAM_BUFFER_SIZE; return PROFILE_SUCCESS; @@ -89,21 +80,19 @@ static int stream_new(struct luam_Sysprof_Options *options) static int stream_delete(void *rawctx, uint8_t *buf) { - struct devnull_ctx *ctx = rawctx; - assert(ctx->fd == DEVNULL); - free(ctx); + assert(rawctx == &context); + /* XXX: No need to release context memory. Just return. */ return PROFILE_SUCCESS; } static size_t stream_writer(const void **buf_addr, size_t len, void *rawctx) { - struct devnull_ctx *ctx = rawctx; - assert(ctx->fd == DEVNULL); + assert(rawctx == &context); /* Do nothing, just return back to the profiler. */ return STREAM_BUFFER_SIZE; } -/* }}} Sysprof "/dev/null" stream helpers. */ +/* }}} Sysprof dummy stream helpers. */ static int tracee(const char *luacode) { ================================================================================ > > > > > > > > Typo: s//the / > > > > > > > > + * FIXME: Make this part test agnostic. > > > > > > Typo: s/test agnostic/test-agnostic/ > > > > > > Nit: TODO looks more valid for me (since it's working). > > > Feel free to ignore. > > > > Fixed. > > > > ================================================================================ > > > > diff --git a/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c b/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c > > index 44421812..036f8141 100644 > > --- a/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c > > +++ b/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c > > @@ -153,8 +153,8 @@ static int tracee(const char *luacode) > > > > /* > > * XXX: The only event to be streamed must be FFUNC at > > - * instruction. > > - * FIXME: Make this part test agnostic. > > + * the instruction. > > + * TODO: Make this part test agnostic. > > Typo: s/test agnostic/test-agnostic/ Fixed (again). ================================================================================ diff --git a/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c b/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c index 8967abc4..a1c4a3ed 100644 --- a/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c +++ b/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c @@ -143,7 +143,7 @@ static int tracee(const char *luacode) /* * XXX: The only event to be streamed must be FFUNC at * the instruction. - * TODO: Make this part test agnostic. + * TODO: Make this part test-agnostic. */ assert(luaM_sysprof_report(&counters) == PROFILE_SUCCESS); assert(counters.samples == 1); ================================================================================ > > > > -- > > > Best regards, > > > Sergey Kaplun > > > > -- > > Best regards, > > IM > > -- > Best regards, > Sergey Kaplun -- Best regards, IM